0

I have an Office365/SharePoint online environment and I need to break role inheritance when document is uploaded to a Document Library. I'm using a Remote Event Receiver for ItemUpdated event because roles are assigned depending on the metadata of the document. (ContentType). It works fine, except because the item not only change role to the document, it changes document library roles too.

So, a few questions:

  • The first, and most important, a Remote Event Receiver is the best approach to do what I need? People point me not to use RER and to use WebJobs or Remote Timer Jobs instead.
  • I only break role inheritance using the SPListItem ID, so, how can be modified if I only use this block of code:

    Utils.ExecuteWithTryCatch(() =>
    {
        modifiedItem.EnsureProperties(w => w.HasUniqueRoleAssignments);
    
        if (!modifiedItem.HasUniqueRoleAssignments)
        {
            modifiedItem.BreakRoleInheritance(false, false);                
        }
    });
    

Any help would be appreciated,

Thanks in advance!

0

I guess you have gone through the function BreakRoleInheritance.

I have also done this but I used BreakRoleInheritance(true,true)

Try this once.

And as per your question I guess RER is better approach as compared to other WebJobs and TimerJobs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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