Has long been plagued by Moss's workflow permissions issues.
Although we assign a task to someone, in fact, all users who have edit permissions in the task list can edit the task.
And we don't want users to see tasks that don't belong to them.
I have tried to solve this problem by using the following two methods.
1. Change the view of the task list.
Usually we assign a workflow task to someone or a group, so my idea is to merge the My Tasks view of the task list with the My Users group view into a new all my tasks view;
Set the all my Tasks view as the default view;
Delete the remaining views;
Remove user permissions to create views;
It looks good, but I didn't even make the first move.
2. Customize a EventHandler
Remember that a friend in the garden wrote an article about controlling workflow permissions by developing EventHandler.
The idea is to customize a EventHandler for the task list so that the task list can automatically change the permissions of the item when it is added.
By customizing EventHandler, you can actually implement the assignment of permissions for a task, but it raises additional questions, such as using ontaskchanged activity in my workflow to catch changes to a task. But because after the task was created, EventHandler immediately changed its permissions, So there is a small error in the workflow.
Oddly enough, though, the workflow has been incorrectly displayed in the document library, but in fact the flow is still normal.
I've been adamant that the permissions on the task list should be configured in Moss, not within the workflow, and then I finally found out I was wrong.
We use CreateTask activity to create a task, createtask activity has a hybriddictionary type of attribute called Specialpermissions.
This property represents the special permission for the task, and if special permission is specified, the created task no longer inherits the permissions of the task list. So we can assign this "special permission" before creating a task.
1. Create a new global contact object to store the assigned object
Contact assignee=default(Contact);
2. Get the assignee object from the initialization form in the onworkflowactivated invoked event
assignee=Contact.FromName(init.contact [0].DisplayName,workflowProperties.Web);
3. Bind the CreateTask Specialpermissions property to the new Specialpermissions object in the Properties panel