Business Rule Running twice, no current.update()

kgomez222
Tera Contributor

Hey all, my business rule seems to be running twice and im quite stuck on it and not sure whats going on.

this business rule is triggered on update, and noticed on the debugger that it seems to go through the function twice.

 

here is my code:

 

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

// Add your code here
var targetTable = new GlideRecord('incident_task');
var shortDes = current.short_description;
targetTable.addQuery('parent', current.sys_id);
targetTable.addQuery('active', true);
targetTable.query();
if (targetTable.getRowCount() > 1) {


gs.addInfoMessage('Incident cannot be resolved because all incident tasks are not closed');


current.setAbortAction(true);


} else {
gs.addInfoMessage('No tasks available!');
}


})(current, previous);

 

here is when it runs:

kgomez222_0-1670262068535.png

 

 

1 ACCEPTED SOLUTION

Mike_R
Kilo Patron
Kilo Patron

For the filter condition, change it to 

State changes to Resolved.

View solution in original post

2 REPLIES 2

Mike_R
Kilo Patron
Kilo Patron

For the filter condition, change it to 

State changes to Resolved.

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Yes as Mike suggested please try the condition to State changes to Resolved.

 

Because currently your state BR will run anytime if it updated and state is resolved.

 

Thanks.