- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 06:58 AM
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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:52 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 07:36 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 07:50 AM
There might be other Async rules running , check queue length in stats.do
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 10:59 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:52 PM
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.