Async business rule sometime working and sometimes not

Debasis Pati1
Tera Contributor

Hi, I have a simple requirement we need to copy the name of the catalog to req short description we cant change all the flow to get this done so i have created an async business rule on the req item table but its sometimes working and sometimes doesn't.

DebasisPati1_0-1665732588233.png

DebasisPati1_1-1665732614304.png

 

Above business rule script:

(function executeRule(current, previous /*null when async*/) {

// Add your code here
gs.log("frombrscript");
var req = new GlideRecord('sc_request');
req.addQuery('sys_id', current.request);
req.query();
if (req.next()) {

req.short_description = current.getDisplayValue('cat_item');
req.update();
}


})(current, previous);

 

@Ankur Bawiskar  Can you please suggest why this doesnt work everytime it works sometimes only.

 

Regards,

Debasis

 

 

 

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@Debasis Pati1 

I see the code is fine.

Not sure why it's failing sometimes?

You need to debug in which case it's failing and what's the root cause

Did you try to use flow designer for this as a workaround?

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

Hi @Ankur Bawiskar  we have around more than 100+ flows and for every flow we cant change and get this done that's why I  wrote this business rule i am doubting on the order and priority things .

Can you suggest i did debug but cant find out why there is no such conditions also for which this business rule shouldn't run sometime .

 

Regards,

Debasis

@Debasis Pati1 

you can create only 1 flow which triggers on insert of RITM and it will update the REQ.

let other flows be there no impact with the one you create.

 

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

Hi Ankur,

I tried to create one flow on Ritm table on insert but unable to find ritm table there

DebasisPati1_0-1665739650457.png