Async business rule does not get triggered (not using previous or current)

Senthil Saivam
Kilo Contributor

Hi,

I have a business rule that that is configured to run 'async', but this never gets triggered. If I just change it to run 'after' then it gets triggered. Below is the script (note that I am not using current or previous) and screenshots of how the business rule is configured.

I have used the script debugger with a breakpoint in the first line, but the breakpoint never gets hit when using 'async'.

Please let me know what I am missing.

cheers,

senthil

 

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

try {
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('POST');
r.setEndpoint('https://***');
r.setRequestBody(JSON.stringify({
action: sys_action,
table: sys_action_collection,
workflow: 'D4C27688-CF88-40DD-B90C-3ED91E8A23BB'
}));
r.setRequestHeader('Accept', 'application/json');
r.setRequestHeader('Content-Type', 'application/json');

var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (err) {
var message = err.message;
logError(message);
}

})(current, previous);

 

 

find_real_file.png

find_real_file.png

 

 

1 ACCEPTED SOLUTION

One possible cause could be the sys_action or sys_action_collection may not be available for async BRs. Try hard-coding those values and if it works, then those variables are the issue.

View solution in original post

8 REPLIES 8

Priyanka_786
Tera Guru
Tera Guru

Hi,

I suggest to check first if there are any existing  async BR with same order on incident table, if yes, change the order according to which BR you want to execute first.

Please mark my answer helpful/correct if it helps you.

Regards,

Priyanka

RaghavSh
Kilo Patron

There might be other Async rules running , check queue length in stats.do


Raghav
MVP 2023

Senthil Saivam
Kilo Contributor

Priyanka, I made sure that this is the only async BR on incident and it didn't seem to help. 

 

Raghav, the queue length is 0 and all the Scheduler Workers are idle.

Background Scheduler
Number of workers: 8
Queue length: 0
Mean queue age: 0:00:00.000
System ID: app131160.ytz3.service-now.com:dev58167002
Total jobs: 382715
Total burst workers: 0
Scheduler run state: true

One possible cause could be the sys_action or sys_action_collection may not be available for async BRs. Try hard-coding those values and if it works, then those variables are the issue.