how to set RITM to closed incomplete when approval stage is rejected?

smahmud
Tera Contributor

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!

3 REPLIES 3

Dr Atul - LNG
Tera Patron

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.

Ankur Bawiskar
Tera Patron

@smahmud 

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.

AndersBGS
Tera Patron

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.