Forum Discussion

vassp1980's avatar
vassp1980
Copper Contributor
Jun 21, 2024

Need PNP Search results webpart to display metadata column that I added in a SharePoint library

I have an issue trying to get a SharePoint Doc Library metadata column to show up in PNP Search results webpart. Here are the details:

  • I have a SharePoint Site where I am just leveraging the default document Library "Documents".

  • In this Library, there are the default columns "Name", "Modified" etc. I have also created a new Metadata column called "Document type" that holds values "Test" and "Production" as choice values.

  • I have created two folders in this Lib called "Test Docs" and "Production Docs"

  • I have configured the library settings such that when user uploads document into "Test docs" folder, the column "document type" automatically gets tagged with the value "test". Similarly when a doc is uploaded to the "Production docs" folder, this column gets tagged with value "Production". See example image below:


    • I have then setup PnP Search webparts in a page in this Site. The PnP Search results webpart in this page refers to the "Documents" library above, and to return the results based on the "PnP search box" search.

    I am having trouble getting the PnP search results webpart to display the metadata column which I created in the library "Document type".

    I need "document type" displayed in the PNP Search results webpart, as I need to restrict user access based on the tag value of the document in this column. So 2 things I am trying to achieve here :

    1. Get the "document type" metadata column to appear in PNP Search results webpart, but I am unable to add this column to the PnP search results webpart view.  I  cant see this column in the list of columns when I edit this webpart (Please advice if I should do some mapping of that document type column to get it to show in the webpart view):



    Please advice.

     

    2. Once the column is displayed in the PnP search results view, I need to setup the following restriction.

    - When a user of country A logs in, they should be able to only see the documents tagged as "Test" in the document type column. Same way if a user of country B logs in, they should only see the documents they are supposed to see (for eg "Production" tagged docs).

1 Reply

Resources