Automatic process version upgrade

02 Jul

First of all… there are terms and conditions. This won’t work in all cases, and for all intents and purposes it’s a bit of an ugly hack, but there are times when something like this is needed (you have loads of live processes which need a new data field urgently, or a new action needs to be added to an activity to bypass a bug and there are live instances which are not yet in error state, etc).

So here’s one way to do this:

  1. Store a “Version” data field in the workflow and keep the latest version label in the .Net app’s app.config file
  2. Catch all exceptions for setting/reading data fields and executing actions
  3. If you get an exception then get the Version data field from the workflow. If it doesn’t exist, upgrade the workflow. If it’s different to the one in the config file, upgrade the workflow.

Upgrading the workflow:

  1. Use the “Process Data” SmartObject to read all the process level data fields from the old process and create a Dictionary out of it.
  2. Create a new instance of the workflow and send it to a holding activity (just a code event with Sync = False). Use the dictionary to set all the data fields so that they are copied from the old process to the new process.
  3. Use the “Activity Instance” Smartobject to get a full list of all activity names for the old workflow and then use a GOTO to go to the most recent Activity.

Obviously there are loads of cases where this won’t work (for example if a later version deleted an activity or data field) but in our case I’m surprised at how well it works. There are also ways of migrating the workflow history over, but that’s a bit more complicated and probably the subject of another post…

Leave a comment

Posted by on July 2, 2013 in SmartObjects


Leave a Reply

Your email address will not be published. Required fields are marked *