Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Business rule is running twice with async and update?

Santhosh15
Tera Guru

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);

16 REPLIES 16

Dhruv Chandan
Giga Guru

Hi @Santhosh15 ,

 

In the trigger condition for BR, could you check if the conditions are being fulfilled after the BR updates?

If yes, then you could probably update the trigger condition with unique keys which will make sure it doesn't get executed after a single update unless the value changes.

 

Hope this help.

Hello Dhruv,

 

This is having specific conditions are being fulfilled after the BR updates

GeraldKirby
Kilo Sage

Hi @Santhosh15 ,

 

You shouldnt be using current.update in a business rule.

Here's guideline from servicenow.

Recommended Practices in Using current.update() in Business Rules - Support and Troubleshooting (ser...

Hello Kirby,

 

Is there any alternate solution for this issue ?

 

Thank you