0

I have the following code inside my remote event receiver, where i am trying to remove a user from a list item which have unique permission:-

User oUser = context.Site.RootWeb.EnsureUser(linemanagerUser.LookupValue);
context.Load(oUser);
context.ExecuteQuery();
currentItem.RoleAssignments.RemoveById(oUser.Id);

but seems RoleAssignments does not contain RemoveById as in the server-side object module.. so can anyone advice on this please?

Error i got on my above code:-

'RoleAssignmentCollection' does not contain a definition for 'RemoveById' and no accessible extension method 'RemoveById' accepting a first argument of type 'RoleAssignmentCollection' could be found (are you missing a using directive or an assembly reference?)    
1

You can try the below code :

currentItem.RoleAssignments.GetByUser(oUser.Id). DeleteObject () 

Or

   currentItem.RoleAssignments.GetByPrincipal(oUser.Id). DeleteObject () 

For details example, you may refer to the below article :

Remove permission in Sharepoint List using Client Object Model

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.