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

前端 未结 6 1759
挽巷
挽巷 2020-12-12 01:09

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 wan

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 01:41

    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.

提交回复
热议问题