Forum Discussion
Brian Jacobsen
Feb 08, 2018Copper Contributor
Apply default compliance label to document library from code (SPO)
Targeting Office 365 / SharePoint Online, we are creating labels in the Office 365 compliance center, and would like to assign these as default labels in document libraries through code (e.g. CSOM/RE...
- Feb 08, 2018Yeap, not to much information about this...have you read this: https://social.technet.microsoft.com/Forums/en-US/a0617140-5197-4908-8799-9e6021c8d70b/programmatically-apply-label-to-items-in-this-list-or-library?forum=onlineservicessharepoint
Feb 08, 2018
Yeap, not to much information about this...have you read this: https://social.technet.microsoft.com/Forums/en-US/a0617140-5197-4908-8799-9e6021c8d70b/programmatically-apply-label-to-items-in-this-list-or-library?forum=onlineservicessharepoint
- Brian JacobsenFeb 08, 2018Copper Contributor
Hi Juan Carlos,
thanks hadn't seen that one - I will check it out and put a result here :)
/Brian
- Brian JacobsenFeb 08, 2018Copper Contributor
I can see that I can set the label on a document but I cannot see how to change the default label for a document library - the below will change the label of a document:
$list = $ctx.Web.GetList("/sites/somesite/somedoclib") $ctx.Load($list) $ctx.ExecuteQuery() $item = $list.GetItemById(DocumentItemID) $ctx.Load($item) $ctx.ExecuteQuery() $item.SetComplianceTagWithNoHold("MyLabel") $item.Update() $list.Update() $ctx.ExecuteQuery()I will consider to add an ItemAdded remote event receiver and set the label when an item is added to the library (allowing the end user to change it if required) - but thanks for the pointer
- Feb 08, 2018
What about using Flow or Webhooks instead of a Remote Event Receiver?