- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 04:24 AM
Need to restart the workflow.
Approval got skipped somehow and workflow is struck. Please let me know how to restart.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 04:52 AM
you can use this script in background for your table record to delete older context and attach new workflow context
(function(){
try{
var gr = new GlideRecord('change_request');
gr.addEncodedQuery('YOUR QUERY HERE'); // PASS your QUERY HERE
gr.query();
while(gr.next()){
// cancel old workflows running
var flows = new Workflow().getRunningFlows(gr);
while(flows.next()) {
new Workflow().cancelContext(flows);
}
// attach the new context
var wf1 = new Workflow();
wf1.startFlow(wf1.getWorkflowFromName('give the workflow name'), gr, 'update');
}
}
catch(ex){
gs.info('Exception'+ex);
}
})();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 05:17 AM
Hi,
So it is adding new context but approval is getting skipped
Did you check any user is being set in that user approval activity?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 05:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 05:44 AM
Hi,
can you share the script you are using as per what I shared?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 06:10 AM
(function(){
try{
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('numberSTARTSWITHRITM0029578'); // PASS your QUERY HERE
gr.query();
while(gr.next()){
// cancel old workflows running
var flows = new Workflow().getRunningFlows(gr);
while(flows.next()) {
new Workflow().cancelContext(flows);
}
// attach the new context
var wf1 = new Workflow();
wf1.startFlow(wf1.getWorkflowFromName('IT-User Support'), gr, 'update');
}
}
catch(ex){
gs.info('Exception'+ex);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2021 06:36 AM
Hi,
so is that not cancelling old and attaching new context?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader