Lars Nielsen's Discoveries

December 28, 2010

Update the approval status in a SharePoint Designer workflow

Filed under: Publishing,SharePoint — Lars Nielsen @ 8:49 pm
Tags: ,

I recently had to build a workflow in SharePoint Designer to model a fairly lengthy approval process for policy documents involving multiple stages of review, each of which has to be passed before the draft document moves to the next review stage. The workflow itself was quite long but essentially boiled down to a series of repeated steps. Each step involved assigning a task to a reviewer (or reviewers) and then updating the status of the document to show what stage it was at. The Policies document library has enforced check in/out, version control, and content approval all turned on. I also needed a field called Review Stage to show what stage the document was at – that was a simple choice field with 7 different stages.

Version History

The obvious thing was to add the Review Stage field to the document library.  After some playing around with the workflow, however, I decided to do things a more complex way.  I created a new list called Document Review Stages with two fields, one was the choice field Review Stage and the other was a number field called DocumentID.  For each policy document in the document library, there is a corresponding entry in the Policy Review Stages list.  The DocumentID holds the ID (the built-in column that SharePoint populates automatically) of the policy document.  In other words, I effectively created a one-to-one relationship between the Policies document library and the Policy Review Stages list.  Of course, this being SharePoint and not a full-blown database, this isn’t a proper relationship – there’s no enforced referential integrity, no cascading updates, etc.  But the basic principle is the same.

So why did I do it in this convoluted way?  Well because the Policies document library has enforced check-in/out and major/minor version control.  So suppose I had the Review Stage column on the Policies document library itself.  That would mean any change to the document, even just changing its metadata, would create a new version.   And that means that the workflow, if it wants to progress the document to the next review stage, would have to first check out the document, then set the Review Stage field, then check the document back in again.  And you’d then have 2 versions of that document, both exactly the same in content, but with different Review Stage metadata values.  This would result in a confusing version history for each document, with some genuinely different versions of the document (edited by different reviewers) but also many identical copies of each document created automatically by the workflow as it moves the document through the review stages.  By moving the  Review Stage column to a different list, the workflow can update the Review Stage field without creating a fresh copy of the document in the version history. That makes the version history much cleaner and more readable.

Approval Catch-22

This being a SharePoint Designer workflow, not a Visual Studio one, I had to attach it to the Policies document library.  I got the workflow to find the Policy Review Stages list item related to its corresponding policy document, and update the Review Stage column on the list.  So far so good, but then right at the end of the workflow, the last step was to make the document go live by setting its approval status to be “Approved”.  There’s a special workflow action to do just that, so it seems easy enough.  But there’s a catch.  If you want to make the document Approved status, you have to change it, and the workflow complains if you try to change it without first checking it out.  OK, so you change your workflow to check the document out first, and then approve it.  But now the workflow complains because you can’t approve a document that is checked out.  Catch-22!

So how do you get round this?  Well you can use the Start Another Workflow action to start the normal Approval workflow on the document.  The built-in Approval workflow can work with a document that’s not checked out.  So you end your workflow early, before the final approval task is allocated, and hand off control to a standard Approval workflow to manage the final approval step.

Advertisements

5 Comments »

  1. Great post, Lars. I wanted to let you know I wrote a post on this topic last night and posted this morning, and in my research ran across your blog post. I gave you credit here http://www.andrewalaniz.com/2011/02/catch-22-approval-sharepoint-designer.html.

    Comment by Andrew Alaniz — February 7, 2011 @ 2:27 pm

  2. […] Today 02/09  I began blogging on this, and found someone else's blogpost from Dec 2010 who also blogged on this exact topic.  Though I never saw his blog post prior to writing this, credit to Lars Nielson. […]

    Pingback by Catch 22 for Approval Workflow in SharePoint Designer | The MOSS Blog — February 9, 2011 @ 5:10 pm

  3. […] –I began blogging on this, and found someone else’s blogpost from Dec 2010 who also blogged on this exact topic.  Though I never saw his blog post prior to writing this, credit to Lars Nielson.  […]

    Pingback by Catch 22 for Approval Workflow in SharePoint Designer - Effectus Digital - Effectus Digital — January 19, 2012 @ 7:06 pm

  4. This is not a solution. If you want to automate things, you don’t complicate them by having to go to e-mails and approving manually.

    Comment by anonymous.a — July 24, 2013 @ 10:51 am

  5. […] –I began blogging on this, and found someone else’s blogpost from Dec 2010 who also blogged on this exact topic.  Though I never saw his blog post prior to writing this, credit to Lars Nielson.  […]

    Pingback by Catch 22 for Approval Workflow in SharePoint Designer - Cyber Security And Non Profits — November 17, 2016 @ 2:03 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: