Sunday 23 November 2014

How to implement reusable workflows on multiple lists in SharePoint 2010


Problem

In SharePoint, a List is one of the most usual ways to store data. We can have multiple lists using the same kind of data (i.e. the Finance and Sales department lists could share the same kind of employee data -- name, address, experience in years and experience level). Now in such a scenario, what if one wants to implement a single centralized workflow which would apply the same automation process to both lists?

Solution

For such a scenario, SharePoint 2010 has introduced a new kind of workflow which is called a "Reusable Workflow". One use of this kind of workflow is to create it and attach it to different lists. This would be created on a content type. So it could be attached to only the lists which implement the same content type on which the reusable workflow is created.

Let us start by creating a content type. Create a content type similar to what is shown in image (below) and name it "EmployeeContentType". Also create two lists. One named "Sales" and the other named "Finance", both using the same content type.



Now open the web application in SharePoint Designer 2010 and click on workflows. On the top ribbon, click on reusable workflow.




Provide a name to the workflow and select the content type on which the workflow should be created. In our case it is "EmployeeContentType".



Now we have added a simple workflow which will update the employee experience level field according to the years of experience of employee.



Save and Publish it. Now for attaching it to multiple lists, you need to check with which list the workflow could be attached? To do so, click "Associate to List" on the top of the ribbon of SharePoint Designer. At the back end, a web service will fetch the list depending upon the content type applied to the list. In our case there are two lists "Sales" and "Finance". Click on "Sales".



A window will appear which would be similar to an out of the box workflow creation window. Here we need to take care of 4 things:
1) Select the same content type on which the workflow is created -- which in our case is "EmployeeContentType".
2) Select the name of the reusable workflow (which in our case is "EmployeeWF").
3) Provide a unique and meaningful name to the workflow for identification.
44) Configure the start options of the workflow as required.


Click for larger image

After performing the above steps, create the workflow. Now we have a sales list with some data.



Now to trigger the workflow, one can edit the items and save it -- accordingly the workflow will update the experience level field values.



Perform the steps for associating the workflow to the finance list until updating the values just like we did in the sales list.



Now the finance list will share the same kind of workflow and values updated accordingly.

Next Steps

  • Use a reusable workflow, to create a similar workflow for multiple list.
  • Use it to reduce redundancy as well as to maintain a single, centralized workflow
  • Return to MSSharepointTips to read about other topics and ideas.
  • Check out MSSQLTips.com for great information about Microsoft SQL Server.




Reference:

http://www.mssharepointtips.com/tip.asp?id=1095

No comments:

Post a Comment