Hi,
This is my first Blog :)
I have worked a little on State Machine workflows in the project i am working on. The solution is specific to WF and .NET 3.0 project which uses MOSS .
I had faced a problem of assigning permissions. You might be wondering, What permissions! I will go a little deep into delving the information. When a task is created for some user say, user A in a typical State of a approval state machine workflow, the permissions are not automatically set to that user alone :( . Any person i e B C or D can click on the task and execute the task. To get to a solution, i tried giving specific permissions to the Tasks list. But what i was actually doing was just delaying the imminent problem, which was the inherrent problem in the workflow itself. I searched through the net and found 2 alternative solutions which were much better and error proof.
One is in the Create Task properties, where we can set Special permissions for Groups or users, wherein the initial permissions will be over-ridden. And the other is to set Roles in the OnTaskChanged event handler properties. These roles which will used to validate against any incoming events.
I was successful in finding a solution using the first method. I was unable to do so using the second method. The second method needs a Class which inherits from the parent class SPRoleType and this class must be used using the System.Workflow.Activities.WorkflowRoleCollection class. I was not able to do it. (In case you gets to know how to use this method, please reply.)
Coming to the part which i successfully completed, all that is to be done is, create a System.Collections.Specialized.HybridDictionary task1Permissions type for the task mentioned.
i.e
public System.Collections.Specialized.HybridDictionary task1Permissions = new System.Collections.Specialized.HybridDictionary(); //Define this as variable
In the create task event handler write this piece of code.
this.task1Permissions["Reviewer"] = SPRoleType.Contributor;
this.task1Permissions["Approver"] = SPRoleType.Contributor;
this.task1Permissions["Group Members"] = SPRoleType.Reader;
this.task1Permissions["Group Visitors"] = SPRoleType.Reader; // all the groups in the sharepoint site must be assigned permissions.(over-ridden)
This did the trick for me.
Hope it helps.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment