Using Flow designer cancel sctask if RITM is Closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:21 AM
Hi Everyone,
I have a requirement to be able to Close a Request Item at any time with Closed state and associated sctasks are completed. Is this possible in the flow as I realize best practice is to have RITM close after tasks are all closed.
Just seeking knowledge if anyone knows how to achieve this.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 10:31 AM
Hi Gemma,
Can you clarify a bit? The title says that you want to cancel tasks when the RITM is closed, but then in the description you say you want to to close the RITM when the associated tasks are closed. Which are you looking to do? Either way, both of these would be achievable with a script step in your flow, however if this is not part of a bigger flow, I would say that a business rule would be a better option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:25 AM
I'm sorry I was not clear. They need to be able to close or cancel a Request Item and then as a result have the associated open sctasks closed. Not sure best way to acheive this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 12:39 PM - edited 05-25-2023 12:39 PM
In that case, I would create a business rule on the RITM table (sc_req_item) to trigger on update when status is canceled or complete. Check the "Advanced" checkbox and you can use a script like:
var gr = new GlideRecord("sc_task");
gr.addQuery('requested_item', current.sys_id);
gr.query();
while(gr.next()){
gr.status = '3';
gr.update();
}
Here I set status = 3, as that is the backend value of "Closed Complete" on my instance, but you might want to check that that is what it is for you. This script could also be used in a script step in the flow designer, you would just have to set the trigger to be on update of RITM, then replace current.sys_id with your trigger variables sys_id. With this method, you would also want to do a check to make sure the RITM was updated to closed/canceled before running the script.