- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 04:25 PM
I see from this link, https://community.servicenow.com/thread/236445?q=How%20to%20revert%20workflow
that one can revert to a prior workflow with this code:
For deactivating the current.
var getInc = new GlideRecord('wf_workflow_version');
if(getInc.get('3b95753ad0d60200085a28e2b5794e1e')) //change
{
getInc.published=false;
getInc.update();
}
To publish old one
var getInc = new GlideRecord('wf_workflow_version');
if(getInc.get('3b95753ad0d60200085a28e2b5794e1e')) //change
{
getInc.published=true;
getInc.update();
}
I understand one can not revert through the UI interface that this needs to be done pro-grammatically, but, couple of questions.
1) From the example above, I am guessing '3b95753ad0d60200085a28e2b5794e1e' is the reference to a specific workflow version.
Is that the same string I see in the name when I export the workflow to a .XML file?
2) Where exactly do I go to run that code? Would I run that as a new Fix Script?
Would this work ?
a) Export a working workflow.
b) Delete the problematic workflow (Ah, scratch this, I see it will not let me delete the current workflow).
c) Import the working workflow version
Thank you in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 01:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 01:12 PM
Yes, it is "Scripts - Background" from left navigation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2017 08:06 AM
Hello Deepak
Can this be captured in a update set?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2017 11:43 PM
No you can't. Admin have to run Background script manually on all instances.
You can use Fix script and capture it in updateset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 01:25 PM
Not sure why this didn't come up in my initial search but this was helpful:
Background Scripts — ServiceNow Elite
After setting account to security_admin, was able to see the Scripts - Background.
After substituting in the relevant workflow Sys IDs, in the code snippet above:
A) Tested just setting the current workflow to unpublished, first. Worked fine.
B) Ran the second code snippet and everything worked fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2021 12:41 AM
The easiest way is
- Go to the workflow record in the wf_workflow table
- Right click in the form header, go to 'Show File Properties'
- Add the 'versions' related list to the form if it's not already there
- Right click the version you want to revert to, click 'Revert to this Version'
- Click 'Ok' on the dialog, and the workflow is reverted
Thanks
Manirul