- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 09:41 PM
Hi Community,
I want to auto close SC task once approval on ritm is approved. I have a workflow which is auto closing RITM once SC task is set to closed complete.
Thanks,
Poorva Bhawsar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 10:57 PM
Hi @Poorva Bhawsar ,
Add an condition after your approval activity block as shown below:
1.Add a Run Script activity block connecting your approval step and then set the state of the catalog task to closed complete :
Script to be used inside Run Script in above diagram:
closeTask();
function closeTask(){
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query();
while(gr.next()){
gr.state = 3;
gr.update();
}
}
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 11:09 PM
Hello @Poorva Bhawsar ,
You can achieve this with your existing workflow itself, Simply insert a "Run Script" activity immediately following the approval step, connecting it to the approval's approved output. This ensures that the script runs only when the approval is successfully approved. Within the "Run Script" activity, incorporate the following code:
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.addQuery('state', '!=', 3); //3 is closed complete value of Sc task
gr.query();
while (gr.next()) {
gr.setValue('state', 3);
gr.assigned_to = 'd4fdf4b7dbe01f00d27a00b5ca96195a'; //set the catalog task fields which are mandatory while close completing the task.
gr.update();
}
I have Tested the above code and other functionality from my end and its working as expected.
Please le me know your views and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 09:56 PM
Hi @Poorva Bhawsar ,
Add an update action with Flow Designer and set the RITM stage to Completed. This will trigger business rules to close the RITM and the Request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 10:04 PM
I have workflow instead of flow. I want to set sc task as closed complete once approvals are approved on ritm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 10:57 PM
Hi @Poorva Bhawsar ,
Add an condition after your approval activity block as shown below:
1.Add a Run Script activity block connecting your approval step and then set the state of the catalog task to closed complete :
Script to be used inside Run Script in above diagram:
closeTask();
function closeTask(){
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query();
while(gr.next()){
gr.state = 3;
gr.update();
}
}
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 11:09 PM
Hello @Poorva Bhawsar ,
You can achieve this with your existing workflow itself, Simply insert a "Run Script" activity immediately following the approval step, connecting it to the approval's approved output. This ensures that the script runs only when the approval is successfully approved. Within the "Run Script" activity, incorporate the following code:
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.addQuery('state', '!=', 3); //3 is closed complete value of Sc task
gr.query();
while (gr.next()) {
gr.setValue('state', 3);
gr.assigned_to = 'd4fdf4b7dbe01f00d27a00b5ca96195a'; //set the catalog task fields which are mandatory while close completing the task.
gr.update();
}
I have Tested the above code and other functionality from my end and its working as expected.
Please le me know your views and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket