
Some days back I was faced with a task of changing the behavior of the list new /Edit form based on the user presence in a particular permission group.
Problem Statement: If the user was present in “Members” group I need to hide some fields and if he was present in the “Owners” Group, I need to show all those fields.
Solution: By calling the GetGroupCollectionFromUser operation of the
Users and Groups Web Service, you can determine whether your user is in the group. I got this from
Marc post.
The only small issue fixed in that post code was that it worked not on every browser, hence I need to modify it a little to support cross browser. I used responseText instead of responseXML.
- First we need to add JavaScript directives to the page, I have provided the CDN link which you can directly use or can download the libraries to use it.
- Then include the below script to check the current logged user’s group
These scripts can be used on CEWP to achieve the desired result.