views:

63

answers:

5

I have a list (assume an issues list) and there is a workflow associated with it. The workflow can adjust the status column of the item to "Closed". Once an item's status is closed, I want to make it read-only so that noone can edit the item or create another workflow instance for that item.

What's the best way to achieve this?

A: 
Right Click the ListBox Control 
Go to Display Tab 
Click on Conditional Formatting 
Click on Add 
If this condition is true --> Selected the condition 
 Disable the control
zod
Not sure if I understand it. Are you suggesting to follow these steps in Sharepoint's browser UI?
Ashish Patel
@Zod: I think Ashish is talking about the form in SharePoint. This isn't a custom ListBox.
Kit Menke
+2  A: 

There are item-level permissions that can be set, so you can override list-level permissions on an item-by-item basis. Adding this functionality into your existing workflow probably makes the most sense, but of course there is nothing out-of-the-box that SharePoint provides you.

Luckily, you can extend SharePoint's workflow by creating your own custom actions. The process for doing this in SP2010 is fundamentally the same as 2007; check out this MSDN tutorial for an overview of the process.

There is also a convenient package of custom activities provided in an open-source product called SPDActivities at CodePlex. Specifically of interest to you is the Grant Permission on Item activity. Even if you opt not to use the whole package, you can examine the source code and see about implementing your own version of it (I did something similar for a past project).

Once you have a workflow action for setting an item's permission level, simply add a step to your existing workflow to set Read permission for the affected audience or group.

CBono
Thanks! I was considering this and if I go for it the pointers you gave would save a lot of time for me. I am also waiting for other options as suggested by Kit Menke along with my comments to his answer.
Ashish Patel
+1  A: 

Have you looked at SPUtility.js? You could get the value of your status field, and then if it is Closed, make the other fields read only (or hide them). This is done using JavaScript that is added in a content editor web part on your EditForm.aspx.

var myChoiceField = SPUtility.GetSPField('Single Choice Field');
if (myChoiceField.GetValue() == 'Closed') {
    SPUtility.GetSPField('Field A').MakeReadOnly();
    SPUtility.GetSPField('Field B').MakeReadOnly();
    SPUtility.GetSPField('Field C').MakeReadOnly();
    // etc..
}

Full disclosure.. this is an open source library I maintain. I've tested it with SharePoint 2007 only, but it may also work with SharePoint 2010 (unfortunately I don't have access to a SharePoint 2010 environment to test).

Kit Menke
The library seems be interesting and I will try it out after evaluating all other options. I would prefer a server side solution. modifying permissions is one option as suggested in one of the answer but I want to avoid that because I am not a fan of too many granular permissions. How about this combination: 1) Intercept a list item event which rejects the change if item was closed 2) use your library to make them read only so that users can not change the item from default UI. Thank you.
Ashish Patel
An event receiver is probably the most robust option. Honestly, you probably won't even need the JavaScript unless you want to make it immediately apparent the user that they will be unable to change the values.
Kit Menke
+1  A: 

I would attack it one of two ways:

  1. Once the workflow completes and sets the item to Closed, you can break the permissions inheritance from the parent list and set the list item permissions to read only. You could do this within a custom workflow or as either a Workflow or List Item event receiver.
  2. Have an ItemUpdating List Item event receiver that sets properties.Status = SPEventReceiverStatus.CancelWithError if status is Closed.

Personally, I like the first option better as it fits in with SharePoint's security philosophy of not letting the user attempt what they do not have permissions to do. The following code is an example of setting read only permissions on a list item:

item.BreakRoleInheritance(false);
SPRoleDefinition role = web.RoleDefinitions.GetByType(SPRoleType.Reader);
SPRoleAssignment assignment = new SPRoleAssignment(web.AssociatedVisitorGroup);
assignment.RoleDefinitionBindings.Add(role);
item.RoleAssignments.Add(assignment);
Rich Bennema
A: 

Try creating an Event Receiver and handle the deleting event.

ChiliYago