how to set RITM to closed incomplete when approval stage is rejected?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 09:03 AM
I have a couple of catalog items with multiple approvals. I want to set the state to closed incomplete once one of the approvals are rejected. Should I use a business rule for this or change every single one of my flows to reflect this? I would prefer to use a business rule as I have more than 30 flows. If I do need a business rule, can somebody help me write it please?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 09:10 AM
Hi @smahmud
Is this in 1-time activity then use the background script but if it is applicable for the furture as well, then update the flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 09:14 AM
you can use after update BR on sysapproval_approver table
Condition: State Changes to Rejected
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
if (gr.next()) {
gr.state = '4';
gr.update();
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 01:33 PM
Hi @smahmud ,
I do acknowledge what @Ankur Bawiskar for creating a business rule, but I would simultaneously advocate for changing the flows which is the root instead of making a work around. By changing the flows of might take more time to maintain right know, but will make it easier in the future.