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.
问题:
回答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.
回答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
回答3:
I know you can create list views, wich are basically views from a MVC pattern that can represent an insance of a list. Wich in your case would be like, managers ticket list view and TI ticket list view. You should search on List Views for sharepoint. Hope this helps.
回答4:
I had to do this exact same thing in my organization where we were building a helpdesk system. The users only needed a few fields like Subject, Description, Due Date, where as the helpdesk officers had a whole host of fields including notes, assigned to, etc.
The easiest way is to create a custom NewForm.aspx for the list.
You can do this in SharePoint designer by copying the existing NewForm.aspx, inserting a custom list form into the page, setting the Visible attribute on the existing one to false, and then removing the rows of information you do not want your users to see.
Then, just apply that NewForm_Trimmed.aspx as the default New Form, and that should do it.
EDIT: SharePoint Designer 2010 makes this process easier... Follow this link: http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-custom-list-form-using-sharepoint-designer-HA010378258.aspx
回答5:
We use Sharepoint Forms Designer tool. It allows to create specific forms for different sharepoint groups.
回答6:
My answer is similar to Paul's but structured a little differently. We had the same sort of requirement on a list form, although in our case we were hiding certain elements based on group membership. You'll need to do the following:
- Add a reference to jQuery and SPServices in either your master page or your edit form. We use the master page option in our environment.
- Ideally, create a new custom edit form for your list and make it the default. It's generally not a good idea to modify the vanilla forms if you can help it.
- Open the edit form in SharePoint Designer and add the following script to it:
$(document).ready(function() {
$().SPServices({
operation: “GetGroupCollectionFromUser”,
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function(xData, Status) {
if ($(xData.responseXML).find(“Group[Name = ’Engineering’]”).length == 1) {
// alert(“You shouldnt see the button.”);
$(“input[id = ’AcctBtn’]”).hide();
}
}
});
});
In your case, you'll actually want to do the opposite - make specific fields hidden by default and then show them if the user's in a group. Simply duplicate the middle line (where it hides the input field) for each element you want to modify. This way you can easily show or hide multiple elements on the form for users in the given SharePoint group.