Forum Discussion

anjani_ch's avatar
anjani_ch
Copper Contributor
Apr 04, 2019

Need to get Site Activity web part data

I have a requirement to display Site Activity in to SPFx webpart (same as the Site Activity web part).

https://user-images.githubusercontent.com/42473451/55487558-3d60a280-5626-11e9-80b6-6d7c3ffeabd5.png

Is there any way to get Site activity programatically by pnp sp or REST or CSOM or powershell.

Please help.

2 Replies

  • William Burke's avatar
    William Burke
    Copper Contributor

    anjani_chwe are in a GCC High tenant, Site Activity is not available. Please post anything you find on this. I will do the same. Thanks

    • Anjani Challamcherla's avatar
      Anjani Challamcherla
      Copper Contributor

      William Burke 

      Site Activity web part displays the Recent documents modified by users in current site.

       

      You can get the Recent documents using search query.

      But before using the search query you must have the SiteId and WebId of site.

      Below is my search query which displays the Recent documents modified by users in current site.

       

      await sp.search({
      QueryTemplate: `((SiteID:${assocSites[j].SiteId} OR SiteID: {${assocSites[j].SiteId}}) AND (WebId: ${assocSites[j].WebId} OR WebId: {${assocSites[j].WebId}})) AND LastModifiedTime < {Today} `,
      RowLimit: 10,
      RefinementFilters: ["FileType:NOT(aspx)", "FileType:NOT(html)", "FileType:NOT(one)"],
      SelectProperties: [
      "ModifiedBy",
      "Title",
      "Path",
      "LastModifiedTime",
      "ParentLink",
      "FileType",
      "ModifiedById",
      "EditorOWSUSER"
      ],
      TrimDuplicates: false,
      SortList: [
      {
      "Property": "LastModifiedTime",
      "Direction": SortDirection.Descending
      }
      ]

      }).then(async (re: any) => {

      console.log(re.PrimarySearchResults);

      });

Resources