The CreatorCon Call for Content is officially open! Get started here.

Kalaiarasan Pus
Giga Sage

Ever wanted to revert a workflow to a previous version?

 

ServiceNow is a highly flexible application, allowing you to build incremental versions of a workflow. But there are times when you want the facility to revert to a previous version of a workflow. There was a similar question sometime back (below) and I had suggested writing a simple script to do this.

 

Re: Can we revert workflow to a previous version?

 

Writing a script is fine but I have seen that people have used this a few times and it would be good to have a solution on the platform instead of writing an ad-hoc script. Since there is no such support out of the box, I have created a simple solution that will provide you an option to revert to different versions of the same workflow.

 

You can find the related updateset here.

 

Usage:

 

  • Installing the updateset will add a new UI action called 'Publish Workflow' on workflow version table.
  • This UI action will be visible only if the current workflow has more than one version and if the current version is not the published workflow version.
  • Open an existing workflow version entry (wf_workflow_version) that you want to revert and click the 'Publish Workflow' button.

 

If you are a beginner on the platform, this solution will help you to learn the following.

 

  • How to create a server side UI action
  • Advanced UI action visibility control using scripts. This is also useful if you ever encounter issues due to the field size of condition field.
  • Gliderecord's update and get methods.
  • Glideaggregate and its usage.

 

Edit: You do not need to use the utility. There is a easier out of the box way to do this. Thanks to @Chris Sanford for pointing this out.

 

  1. Go to the workflow record in the wf_workflow table
  2. Right click in the form header, go to 'Show File Properties'
  3. Add the 'versions' related list to the form if it's not already there
  4. Right click the version you want to revert to, click 'Revert to this Version'
  5. Click 'Ok' on the dialog, and the workflow is reverted
9 Comments