Tuesday, October 15, 2013

Restrict a SharePoint Task to its Assigned User/Group

You may have noticed that when you create a task in a SharePoint Designer 2010 workflow, anyone with "Contribute" rights is able to complete it.  While this is okay for some things, when you are using workflow to automate a business process (as we do with U-LINC), it can be problematic.  So what can be done?

Secondary Workflow to the rescue!

What we need to do is to create an "Assign Permissions" workflow on the "Tasks" list (or the task list that is assigned to the original workflow) that will replace the default permissions on the task list item.  First, you must be logged in as a user that has full control of the site containing the task list.  Open the site in SharePoint Designer 2010, navigate to the Tasks list (fig. 1), and create a new workflow, naming it appropriately (fig. 2).
Figure 1: Task List


Figure 2: Create List Workflow
Next, click the white space below the default "Step 1" and click the "Impersonation Step" button in the "Insert" section of the ribbon (fig. 3).  If you have not clicked in the right area, the button will be grayed out.

Figure 3: Impersonation Step


 Insert a "Replace List Item Permissions" action (fig. 4).

Figure 4: Replace List Item Permissions Action


Click the "these permissions" link (fig. 5) and then click "Add".


Figure 5: Replace List Item Permissions

Check the "Contribute" box, then "Choose" to select the user/group.  Click "Workflow Lookup for a User..." and then click "Add >>", select the "Current Item" as the data source and "Assigned To" as the field (fig. 6).  Click "OK" three times to get back to the "Replace List Item Permissions" dialog box.
Figure 6: Add Contribute Permissions

You can add more permissions for other groups if necessary.  For use with U-LINC, you will want to add "Read" permissions to the U-LINC service account (especially when using the U-LINC for Dynamics GP adapter to view the workflow state in GP).


Once all of the permissions are assigned, click "OK" to close the "Replace List Item Permissions" dialog box.  Now, we need to tell it which list to use by clicking on the hyperlink "this list" and selecting the "Current Item" (fig. 7).  Click "OK" to close.

Figure 7: Choose List Item


The last step is to set this workflow to fire when a new task is created.
Click on the Workflow Settings button in the ribbon, and check the box for "Start workflow automatically when an item is created" in the "Start Options" (fig. 8).
Figure 8: Start Options

Click the Publish button in the ribbon, and you should be all set!