Hide/Show Edit Fields Based on SharePoint Permissions

Posted on June 1 2010 by SmashedLife

I have been looking for a way to hide edit fields based on permission levels in SharePoint. I have done it before using conditional formatting in SharePoint Designer but sadly when you do this, it breaks the form. That is when I discovered SPServices. It is essentially a jquery library that simplifies the SharePoint web services and makes them easier to use.

Based on the following code snippet, I was able to hide the edit field based around the user’s permission level in SharePoint.

$().SPServices({
    operation: "GetGroupCollectionFromUser",
    userLoginName: $().SPServices.SPGetCurrentUser(),
    async: false,
    completefunc: function(xData, Status) {
        if($(xData.responseXML).find("Group[Name='SHAREPOINTGROUP']").length == 1)
        {
            $("#DIVID").hide();
	}
        else
        {
             $("#DIVID").show();
        }
    }
});
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • MySpace
  • Reddit
  • Technorati
  • Twitter

Leave a Reply