Forum Discussion
How to get available classification labels with CSOM?
It appears that you must ExecuteQuery even though the ComplianceTag class is not a ClientObject. The SPPolicyStore in the OP still fails. It is not clear to me what the differences is between SPPolicyStore and SPPolicyStoreProxy.
private static IEnumerable<string> GetAvailableTagsForSite(ClientContext clientContext)
{
var web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();
var tags = SPPolicyStoreProxy.GetAvailableTagsForSite(clientContext, clientContext.Url);
clientContext.ExecuteQuery();
return tags.Select(t => t.TagName);
}- Rahul SrivastavaOct 17, 2017Copper Contributor
Hi Gabriel,
I just read your post, did you manage to get a solution to access labels? I tried at my end as well but could not succeed.
Thanks
Rahul
- Gabriel SmoljarOct 17, 2017Brass ContributorSee the code in my first reply in this thread. That code was working for me. Keep in mind that it can take up to 24 hours for labels to be propagated to a site. Check in library settings before testing your code just to be sure.
- Rahul SrivastavaOct 17, 2017Copper Contributor
Hi Gabriel,
Thanks for your response, my library is showing up the labels. But my requirement is how to get the label value that is applied to my site. For example if my site has been classified as highly confidential, then I need to generate a report which list down all the sites that are highly confidential.
The CSOM release shows a method (public method Microsoft.SharePoint.Client.CompliancePolicy.SPPolicyStoreProxy.GetAvailableTagsForSiteLabel). I tried using this method but getting the count as 0.