views:

454

answers:

3

Hi guys,

Here is situation: There is a list with the fieds: Title, Client, Project, Description. There is a view for analysts with the fields visible: Title, Projec, Description.

All is fine so far as the analysts work with their views and not with the lists. But when they need to modify the records clicking on Edit, they see and able to modify the 'Client' field too.

How to prevent 'Client' field to be available for editing by the group? is there a way in WSS or I need to look for 3rd party list components?

Thanks, Val

+1  A: 

All fields have a set of properties that determine their visibility in forms, such as "ShowInNewForm", "ShowInEditForm", and "ShowInDisplayForm". There's also some for the file dialog, the list settings page, and a few other places, but that's getting past it. Short answer, yes, you can make the field not show up in the edit form with WSS without needing any 3rd party components.

If you need a field that cannot be seen in the Edit Form by anyone (that is, no one should be able to have it in their form), then you need to modify "ShowInEditForm" to be true. This can't be modified directly through the SharePoint UI, but it is extremely simple using the object model.

If you need certain people to edit it at some point through the SharePoint UI, then you'll instead have to create a custom edit form. That's a bit more complex, so I'll hold off on providing that instruction unless you state you need to go down that route (or someone else passes by this answer and requests it). Nevertheless, it is fully possible with WSS 3.0.

EDIT

If you know already know how to insert inline C# code into an ASPX page, you can perform this very simply using SharePoint Designer. First, follow the instructions from this article, especially make sure you don't delete the default list form web part. Now, in the custom list form you added, make it include every field which anyone will be capable of editing. The last step is to make the form hide those fields for certain people. Let's default them to Visible=false, and flip this switch if the user is allowed them. You can do this either by checking if the current user is part of specified groups, or by checking if the user has a certain permission level only held by people of those groups. You'll basically write some code like the following, I'll use checking for a specified group as the example.

using (SPWeb web = this.Web)
{
    SPUser currUser = web.CurrentUser;
    string[] listOfGroups = { "Group1Name", "Group2Name", "Group3Name" };
    foreach (string groupName in listOfGroups)
    { 
        if (currUser.Groups.Contains(groupName))
        {
    //Repeat this for each Control, refer to them by their ID. For example, this is for a control with the ID txtTitle.
            txtTitle.Visible = true;
        }
    }
}

If you don't know inline code, you'll have to write a custom ASPX page with a code-behind. Copy EditForm.aspx into a new file - you should do this after setting up a Custom List Form as per the article. You could also build a new ASPX page from scratch, but make sure you include all of the necessary Content placeholders for SharePoint pages. Now, the page currently inherits from Microsoft.SharePoint.WebPartPages.WebPartPage. We need to create custom code that inherits from that class, and change the page to inherit that new custom code instead. In the custom code, override one of the OnLoad or OnInit methods, and include your check for the user's permissions there as detailed earlier. Compile the code, deploy it to your SharePoint server, and it should be functional.

ccomet
Hi there, thanks for the detailed response.My case is closer to what you desrcribed in the end of your response. I need to enable some user groups to edit only their fields and preventing others from editing or (if it's easier) seeing the others fields. The "ShowIn..." properties will not help cause the are applied to all of the groups.I would really appreciate if you could guide me with your instructions.Cheers,V
val
A: 

If you want to set fields hidden or display them in new form or edit form page of the list...

Go to the list settings. In Advanced Settings, enable "Allow management of content types"

By doing so, you will get a List name Link on the List Setting Page. Open the link and select the fields that you want to hide or uhide using add or remove option.

After saving this, again disable "Allow management of content types" in Advanced Setting...

Thats it :)))

Umang Doshi
Hi Umang, thank for the response. Your way will totally hide the field from everyone thus not allow any of users to edit the field.My task is to have a field hidden only for some users, let's say from "Readers" but the "contributors" can view and edit the field.Thanks,Val
val
A: 

You may now easily customize what fields you show or allow for editing with Malcan Worklow for Sharepoint. You decide who, what and when can edit. Check http://malcan.com please.

Artur