Sharepoint 10 Lists: want to limit form fields per user groups

18,646

Solution 1

Download JQuery and SPServices libraries and place them in a read only document library or in your 14 Hive, whichever suits you. Then edit the NewForm.aspx of the list (with SP Designer) and add in references to the two files.

Add a script tag with the following:

$(document).ready(function() {
    Admin_Group = "My Group Name";
    if(IsGroupMember(Admin_Group))
    {
        $('input[title="Assigned To"]').parent().parent().css("display","none");
    }
});


function IsGroupMember(GroupName)
{
    var isGroupMember = false;
    $().SPServices({
            operation: "GetGroupCollectionFromUser",
            userLoginName: $().SPServices.SPGetCurrentUser(),
            async: false,
            completefunc: function(xData, Status) {
              if($(xData.responseXML).find("Group[Name='" + GroupName + "']").length == 1)                
              {
                  isGroupMember = true;
              }
            }
    });
    return isGroupMember;
}

You might need to check the input selector is correctly accessing the assignedto or what ever field you need to hide but I've used this approach successful in many situations. Make sure the field you hide isn't a required field. Also remember to hide this in the EditForm.aspx too if thats what you need.

Solution 2

You can do this by editing the view / edit form in SharePoint designer or InfoPath, but you need quite a bit of knowledge on XSLT or InfoPath to do tricks like these. For InfoPath see: http://blog.symprogress.com/2011/05/infopath-list-form-hidedisable-fields-based-on-sharepoint-group-membership/

Or you can create custom webparts for every element you need, by using Visual Studio.

Or you can use a product like this, which is by far the easiest way: http://store.bamboosolutions.com/sharepoint-column-level-security.aspx

Share:
18,646
user1146356
Author by

user1146356

Updated on June 28, 2022

Comments

  • user1146356
    user1146356 almost 2 years

    I am creating an Service Request Ticketing System using SharePoint 10 Lists functionality. I want to hide some form fields from the end user when completing the form but want the admin folks to see all the form fields. One example would be hiding the "Assigned To:" form field form end users. Not sure how to do this. Thank you in advance.

  • user1146356
    user1146356 over 12 years
    Do not have this knowledge? Thanks.
  • user1146356
    user1146356 over 12 years
    When I tried to create a new Form I recieved an error message that said "Could not save the list changes to the server." Not sure what that is about.
  • Tys
    Tys over 12 years
    Then you should go for the Bamboo product