Friday, September 30, 2011

Create multi level approval workflow in SharePoint 2010 using Visual Studio


Requirement: We have a requirement to create a Multi-level approval workflow for document libraries. I need to use SharePoint groups for each level of approval/review as there are multiple users need to review the document and approve and don't want to hard code the SharePoint groups. Can we create a custom workflow section where I can set the 'level of approvals' and 'Approvers' for each level when assigning a workflow for a document library

Solution: Create a workflow association page using VS.NET 2008. Refer to my previous post for more info.

Attached the screen shots of final output
Page 1:
Create Multi-level Approval Workflow

Page 2:
Create Multi-level Approval Workflow

The codebehind page of the association page (aspx page) will have the code to create SharePoint groups for "Reviewers"(1st level approval) and "Approvers"(2nd level approval) on submit. All the workflow related activities is handled in the Workflow coding.



Trigger event when workflow is added to a document library

Requirement:  I've created a custom sequential workflow using Visual studio and wanted to create SharePoint group when the workflow is added to a document library.

Issue: There is no event or activity associated to the Workflow which will be triggered when we add a Workflow to a document library of list. Also there is no event associated with document library or list that to be triggered when a workflow is added to it.

Solution: Create an association and initiation form in a workflow using VS.NET 2008. You can use either .aspx or InfoPath forms in a workflow. Association and initiation forms are displayed for users to complete before any workflow actually starts.Association forms are displayed to administrators when they first decide to add or associate a workflow with a particular list, document library, or content type. You can use association forms to let an administrator specify parameters, default values, and other information for the workflow as it applies to items on the list, library, or content type with which the administrator is associating it.

Below are some excellent resource I referred to and implemented successfully. Please refer to
http://msdn.microsoft.com/en-us/library/cc297199(v=office.12).aspx

Workflows for WSS3 Demystifying ASPX forms association

http://sergeluca.wordpress.com/2008/11/20/step-by-step-tutorial-creating-workflows-with-windows-sharepoint-services-and-moss-2007-part-1420-easy-aspx-association-forms-my-small-generic-framework/