How can I set the approval status to approved if there is no approvals attached to the RITM

raj99918
Tera Contributor

Hi 

 

How can I set the approval status to approved on RITM table if there is no approvals attached to the RITM How can I achieve it from Business rule

15 REPLIES 15

Hi @raj99918 

 

Got it. So, BR is one thing, but the best option is Flow. You’ll need to update Flow. Think long-term: BR will be code-based, but Flow will be no-code/low-code.

Also, I recommend reviewing the answer provided by

@Ankur Bawiskar  & @Mark Manders 

*************************************************************************************************************
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]

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

Mark Manders
Mega Patron

This is very risky, unless you have perfect definitions to when this will happen.

You really run the risk of setting the RITM to approved, before the approvals are requested, so keep a good look on how anything is triggered and in which order.

And I agree with @Dr Atul G- LNG: use a flow and if any way possible, the same flow you use for the catalog item, so you can just trigger the approvals and if none, set it to approved.

 

Be advised: ServiceNow's default is 'no approver = auto approved', so if you have inactive users, unfindable groups or whatever, it will skip that step and just approve the RITM. 

Maybe ask yourself the question why you want a RITM on 'approved' state if you don't have approvals. That's a huge red flag when it comes to audits.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Ankur Bawiskar
Tera Patron
Tera Patron

@raj99918 

how will you know in BR etc that there are no approvals.

This you will have to handle in you flow itself and directly set it to Approved

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

Hi @Ankur Bawiskar  I have written this BR for that one:

 

var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval',current.sys_id);
app.query();
var count = app.getRowCount();
if(count==0)
{
current.approval='approved';
current.update();
}
 
 

@raj99918 

but I already told in BR you won't know if approval is there or not for that RITM

What if BR runs and approval is at later stage and not during insertion?

Your logic fails

you know the catalog item, it's flow and that flow will tell if approval is there or not

If not then directly set that field

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