- 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
‎03-26-2024 07:11 AM
Hi JC,
I am also getting the same error, "after" it is working but "async" is not trigerring.
Can you please help me, with how to add this in BR script? Is there any syntax?
Thanks
Balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2022 12:57 AM
Another related question, async BR's on delete action don't have access to current, right? If so, is there anyway to get the sys_id of the deleted record in an async BR? Or is changing the BR to 'after' the only way to get the sys_id of the deleted record?
cheers,
senthil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2022 11:00 AM
You should have access to current. Previous is the one which isn't available on async BRs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2022 11:27 AM
current works for async BR's on create and update but not delete. So if I add 'sys_id: current.sys_id' to the script then it works for create and update but not delete. If this line is removed and there is no use of current then the async BR works for delete too.