Business rule is running twice with async and update?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2023 11:22 PM - edited 02-15-2023 01:29 AM
Hello all,
When I am using current.update() in my code, the business rule is running twice for assigning ticket to some other team.
Please help on this issue.
Code Below:
=================================================
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var httpStatus = current.u_http_status_code;
if (httpStatus == 201) {
gs.log("inside 201 block" + httpStatus);
var seconds = 90;
var second = parseInt(seconds, 10) * 1000;
var start = parseInt(new Date().getTime()) + second;
while (start > parseInt(new Date().getTime())) {
// do nothing
}
gs.log("outside the waitblock while loop response w");
if (current.sys_updated_by != "svc.awx") {
current.assignment_group = "72fb418d13c863004d8e5ce12244b008"; //Unix
current.update();
}
} else {
current.assignment_group = "e6fb018d13c863004d8e5ce12244b0dc"; //ServiceNow Team
current.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 05:18 AM
What is your trigger condition?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 03:06 AM
Hi @Santhosh15 ,
yes because we are setting current.setWorkflow(false); or you need to use before business rule to ignore the current.update();
ServiceNow Community MVP 2024.
Thanks,
Pavankumar