8

I am creating a rollup of Modern team and communication sites that are provisioned in my tenant by creating one SPFx webpart which retrieves the site's title, URL, logo and some other properties using the Search REST API endpoint :

/_api/search/query?queryText='contentclass:"STS_Site"&selectproperties=Title,Path,SiteLogo'

Now, whenever I create a Modern team or communication site, I am able to set the site's classification value.

This value is stored in the site's classification property.

enter image description here

So how do I retrieve this property using SharePoint Search REST endpoints ?

Is there any specific managed property that I need to include or map any crawled property ?

I couldn't find anything related to it using the Search Query tool or checking via the managed and crawled properties in the Search Schema of the tenant.

Appreciate any inputs on this !

1 Answer 1

1

Gautam,

If you visit: https://yourtenant.sharepoint.com/sites/yoursite/_api/web/allProperties

You can see the entire property bar for that site. Look for the property that contains your site classification, then you can add it to your selectProperties in your query.

I hope this helps?

3
  • hey @hugo, unfortunately its not stored as a property bag. It is available via https://yourtenant.sharepoint.com/sites/yoursite/_api/site/classification which is a site collection property. Unforunately, i couldnt find anything related to it in the crawled properties or managed property which made sense. But i could be wrong :( Jan 28, 2019 at 14:43
  • 1
    Gautam, you are absolutely correct. I should have pointed out this article at docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/… which suggests that you can add it to your site's property bag to make it searchable. To quote the article: You can use extension method Web.AddIndexedPropertyBagKey in the ObjectPropertyBagEntry.cs file in OfficeDevPnP Core to store the classification values in site property bags instead of in a list. The method enables property bags to be crawled or searchable. Jan 29, 2019 at 17:29
  • Hey Hugo, unfortunately, we only have modern sites. So, to get this approach to work, i would 1) Need to disable NoScript capabilties, which i dont really want to unless necessary 2) Need to store the classification values, as you mentioned , in property bag additionally. But its going to be a maintenance nightmare because everytime somebody changes the classification value, we need to run a script to update its value. This is not feasible for me unfortunately :( . The approach mentioned in your link would work on classic sites !! Feb 1, 2019 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.