- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 09:28 PM
Hi,
I have made changes to the existing workflow and deployed last week everything is fine but my manager wanted me to replace the new workflow to all the existing RITM's which are currently open.
Can we do that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 09:53 PM
Hi,
you will have to delete the older workflow running context for those RITMs
then using script attach the new workflow to that RITM
example
updateWorkflow();
function updateWorkflow(){
try{
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('YOUR QUERY HERE'); // PASS your QUERY HERE
gr.query();
while(gr.next()){
// delete old context
var gr1 = new GlideRecord('wf_context');
gr1.addQuery('id', gr.sys_id);
gr1.query();
gr1.deleteMultiple();
// attach the new one
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
‎01-12-2022 09:53 PM
Hi,
you will have to delete the older workflow running context for those RITMs
then using script attach the new workflow to that RITM
example
updateWorkflow();
function updateWorkflow(){
try{
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('YOUR QUERY HERE'); // PASS your QUERY HERE
gr.query();
while(gr.next()){
// delete old context
var gr1 = new GlideRecord('wf_context');
gr1.addQuery('id', gr.sys_id);
gr1.query();
gr1.deleteMultiple();
// attach the new one
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
‎01-14-2022 11:05 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Thanks!
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
‎01-14-2022 11:09 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader