Workflow - Stuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 06:42 AM
Hi All,
We have the following workflow for emergency changes:
The workflow has got stuck in the switch. This is because the change source field was not populated.
If the emergency change was raised from an incident or problem then the change source field on the change request gets automatically populate with the severity from the incident or problem.
We have an option to convert a normal change into an emergency change with a related list to add in the incident or problem, however there is nothing in place to auto populate the the change source field, and this is why the workflow has got stuck.
I can manually add in an answer to the change source field, but this does not seem to 'un-stick' the workflow. After I've manually entered the answer into the change source field source I have tried to nudge the workflow in the workflow context menu, but this has also not resolved the issue.
Has anyone got any clues of a way to get the log moving along the workflow again as a temporary measure until we fix the underlying issue?
Any help is greatly appreciated
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 06:51 AM
do you plan to update the change source? if so you could put a wait condition before the switch to wait for "change source" to be populated then execute the switch once you have a value? it doesnt look like if change source is "none" that it goes anywhere. if you update that route in the workflow as well. then you can just write a script to query for the changes that are stuck in the workflow and cancel the workflow then start the new updated workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 07:17 AM
Hi Nathan,
Thanks for the above. How would I cancel and then start a new workflow?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 07:37 AM
well once you modify your current workflow and push the updates to prod. I would create a scheduled job to run on demand. you need to know where you can effectively query the right record in production that have this issue, so you are not canceling and restarting the wrong record. <=== There is your Risk. Of course test this all out in Dev first right. Then in your scheduled job you would create your gliderecord variable and query for your changes then iterate through and use the workflow script API to cancel and start a new workflow http://wiki.servicenow.com/index.php?title=Workflow_Script#gsc.tab=0
something kind of like this.
var gr = new GlideRecord('change_request');
gr.addQuery('add your query here to get affected records');
gr.query();
while(gr.next()){
var workflow = new Workflow();
//cancel all the workflows, where gr is a task record with a workflow context
workflow.cancel(gr);
//start new workflow
var context = w.startFlow('workflow sys_id', gr, 'update','');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 07:40 AM
I havent tested this jsut made it on the fly, but I have done something similar in the past so it should work. just make sure you find out how many records are affect and in your query before you run you throw back a log of how many are captured in your query to match it.
gs.log(gr.getRowCount());