Do i need to Issue ListItem.Update(), when i am executing these commands ( ListItem.ResetRoleInheritance() + ListItem.RoleAssignments.Add() )

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/286116

Pergunta

I am working on a remote event receiver inside SharePoint online custom list. now inside the RER i am getting the item been updated, then reset its role inheritance + add users to the item permission, as follow:-

projectItem.ResetRoleInheritance();
projectItem.BreakRoleInheritance(false, false);
projectItem.RoleAssignments.Add(oUser, new RoleDefinitionBindingCollection(context) { readerDef });
FieldUserValue[] approvers = projectItem["Approvers"] as FieldUserValue[];
                    foreach (FieldUserValue user in approvers)
                            {
                              User oUser2 = context.Web.EnsureUser(user.LookupValue);
                              context.Load(oUser2);
                              context.ExecuteQuery();
                              projectItem.RoleAssignments.Add(oUser2, new RoleDefinitionBindingCollection(context) { contributeDef });

                             }

now i thought to get the ListItem.ResetRoleInheritance() + ListItem.RoleAssignments.Add() working i need to execute ListItem.Update() at the end.. but based on my test the ListItem.ResetRoleInheritance() + ListItem.RoleAssignments.Add() will be applied without having to execute ListItem.Update().. so is my assumption correct? Thanks

Foi útil?

Solução

There is no need to add ListItem.Update() when use reset listItem permission.

Official document about ListItem.Update() for your reference:

https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ee536748(v=office.15)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top