0

I have a list in SharePoint Online and when the user clicks on Edit Item I want to check if the user is a member of a certain group. If not, the edit item event should be canceled.

Now, I've managed to this with save buttons but I cannot figure out how to do this with the Edit Item button.

I would prefer to do this with javascripting and jQuery.

1

sorry, you asked for jQuery, this is without:

  • Add a Content Editor Web Part

    • Use CSS to always hide the button
  • Add another CEWP below the first one (so it executes later)

    • Set the Target Audience to the audiences who may view the button

    • Add CSS to display the button

2
  • nice, could you provide an example? Also the target audience is decided by looking in a user/group field where i evaluate the current logged in user with that field, if field contains a user and the user is the logged in user he/she can edit. If the field contains a group I check if the logged in user is a member of the group. – dadde Feb 22 '17 at 9:45
  • I think your idea combined with my javascripting can solve the issue. Thank you! – dadde Feb 22 '17 at 9:59
0

You should do this by giving the appropriate rights to the group in the list permissions. That way SharePoint will automatically disable the edit button for users without edit rights.
If you do it with javascript there will be some workarounds for users to edit the item anyway (through MS access, or by adding the list web part to some page that doesn't execute your javascript).

You can setup the permissions by going to List Settings -> Permissions for this list -> Stop Inheriting Permissions and explicitly giving the appropriate permissions to the groups or users.

3
  • Yes but that won't work since the list items can be either public (everyone can edit) or private (only creator should be able to edit). Not so worried about the workarounds because the sensitive information is encrypted and useless in other views. – dadde Feb 22 '17 at 0:25
  • It will work. What you're refering to is the Item-level Permissions in Advanced Settings which is different thing. Try this approach and you will see that it works. – Damjan Tomic Feb 22 '17 at 0:28
  • Ok I tried item-level permission in advanced setting but it's not possible there to have both public and private items. It's one or the other? "[Create and edit all items] [Create items and edit items that were created by the user] [None]" – dadde Feb 22 '17 at 0:38

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.