A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Tuesday, September 27, 2011

How to start the default approval workflow programmatically (Via Hugo Esperanca)

Extract

“Today I was trying to find a way to programmatically create a publishing page and start the default approval workflow attached to the pages library. The reason that I had to programmatically start the workflow (instead of relying on SharePoint to automatically start it for me) was because my code was running under the system account (in this case under a WCF web service IIS process) and, since SP1, SharePoint will not automatically start a workflow if the list item is being changed by the system account (see this blog post for more information).

The main requirements were:

1) Determine what is the default content approval workflow associated with the Pages library.

2) Start the approval workflow when a Page is programmatically added to the Publishing Pages list but only if approval is enabled on the list.

3) Pass the default association data to the workflow (without asking the user).

Here is the solution:

For complete post, click here.


No comments:

Post a Comment