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

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

有帮助吗?

解决方案

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)

许可以下: CC-BY-SA归因
scroll top