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 G- LNG
Tera Patron
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.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

AndersBGS
Tera Patron
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.

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/