Sharepoint 2010 : changing the Approval Workflow status when a document is deleted and restored

When an approval workflow is running on a list item (like a document) and when the document is deleted, the document (and the associated workflow) is still in the Recycle bin; if we undelete the document, it get back to its original document library but the workflow status is “rejected”; I don’t think this is a good option: the workflow status should be “canceled” like when you explicitly cancel a workflow or nothing at all, or the workflow should still be active (unless it “timeouted”); how can we change the workflow status when the document ahs been deleted & restored ? By customizing the out of the box workflow, which is now possible in Sharepoint thanks to the new Office Task activity.

To fix this we can create a copy of the existing Out of the Box approval workflow and we will customize it. I will illustrate how to achieve it, it is very pretty easy.

  • Start Sharepoint Designer 2010 and open your web site .
  • Select the Workflows panel :

 

image

 

  • Right click on the “Approval Sharepoint 2010” workflow and select “Copy and Modify”:

image

 

  • In the next window, name your new workflow : “Approval Modified”

image

 

  • The wokflow editor will show up :

image

  • In the workflow editor, click on “start Approval…”
  • In the following window, select the option “Change the behavior of the overall task process” :

image

 

  • Scroll down in the workflow editor and move to the Step “When the item is Deleted”:

 

image

  • Select the End task process instruction and remove it.
  • Add the instruction ( as illustrated in the next picture)

Set workflow status to Cancelled

Stop the workflow and set the log message to “workflow cancelled because the item has been deleted”.

image

  • Click on the Save button in the ribbon and on the Publish button :

image

  • Associate your new workflow template with a new list

 

  • Start a workflow instance on a document :

 

image

  • Delete the document :

image

 

  • Go to the Recycle Bin and restore the document:

image

  • Go back to the document library : you will notice that the workflow status is now“Canceled” and not “Rejected” anymore

image

If you click on the workflow status (here “Canceled” ), you will be redirected to the workflow history and your custom message will show-up :

image

Advertisements

3 responses to “Sharepoint 2010 : changing the Approval Workflow status when a document is deleted and restored

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