Friday, 13 June 2014

Creating a custom sequential workflow in SharePoint 2010

Nice Article by Kalyan

http://www.techbubbles.com/workflowfoundation/creating-a-custom-sequential-workflow-in-sharepoint-2010/

SharePoint supports state machine and sequential workflows. In Sequential Workflow the activities are placed in logical order with a start and an end. Sequential workflows can be used in automated processes where a manual interaction like moving documents to library. In SharePoint, Workflows can be associated with libraries, lists and sites. Site workflows are introduced in SharePoint 2010 and they exist at the site level and can act on all lists and libraries associated in the site. This post outlines the steps to create a sequential workflow in SharePoint.
Create a list and instantiate the workflow automatically when an item is inserted to a list and flow through the process.
1. Create a list in SharePoint called Credit Approval which contains the below three fields
Field Name Data Type Required
Credit Requested Amount Currency Yes
Employment History Choice (Good, Bad and none exist) Yes
Credit History Choice (Good, Bad and none exist) Yes
2. Launch the Visual Studio  2010 and create a new Sequential Workflow as shown below
image
3. Name the workflow project name and say ok. Visual Studio selects the available SharePoint site on the machine and select deploy as Farm Solution in next step
4. Provide a name to workflow and select List Workflow for the workflow template
image
5. Click next to select the list association and task list and workflow history list
image
6. Check how do you want the workflow to start?
image
7. Click Finish button and Visual Studio generates the necessary files. Add LogToHistoryListActivity activity below onWorkflowActivate activity and set the properties as shown below
image
8. Drag an If-else activity to the designer below the logWorkflowStarted activity. Add other activities as shown below
image
9. Select the code condition in properties window for CheckEmploymentHistoryActivity and add the below code
image
10. Now Deploy the project and browse the list in SharePoint and save an item to the list. As there is no user interaction workflow completes and shows as below
image
11. Click on the Completed status of the workflow to see the workflow history.
image
12. After Deploying the workflow to SharePoint then you can then associate it to list , content or site in two ways
  • Manually by using SharePoint interface
  • During the feature activation via feature receiver
13. Navigate to the list settings –> Workflow settings of the list then you need to associate a workflow as shown below
image
click on the Add a workflow link to add a new workflow as shown below
image

No comments:

Post a Comment