Business rule executing twice

Community Alums
Not applicable

Hi All,

 

One of the BR written on sc_request table executing twice,

BR:

find_real_file.png

Advanced :

 

if (current.operation() != 'insert' && current.comments.changes()) {
gs.eventQueue("sc_request.commented", current, gs.getUserID(), gs.getUserName());
}

if (current.operation() == 'insert') {
gs.eventQueue("sc_request.inserted", current, gs.getUserID(), gs.getUserName());
}

if (current.operation() == 'update') {
gs.eventQueue("sc_request.updated", current, gs.getUserID(), gs.getUserName());
}

if (!current.assigned_to.nil() && current.assigned_to.changes()) {
gs.eventQueue("sc_request.assigned", current, current.assigned_to.getDisplayValue() , previous.assigned_to.getDisplayValue());
}

if (!current.requested_for.nil() && current.requested_for.changes()) {
gs.eventQueue("sc_request.requested_for", current, current.requested_for.getDisplayValue() , previous.requested_for.getDisplayValue());
}

if (current.approval.changes() && current.approval=='approved') {
gs.eventQueue("sc_request.approved", current, current.approval, previous.approval);
}

if (current.escalation.changes() && current.escalation > previous.escalation && previous.escalation != -1) {
gs.eventQueue("sc_request.escalated", current, current.escalation , previous.escalation );
}

if (current.active.changesTo(false)) {
gs.eventQueue("sc_request.inactive", current, current.stage, previous.stage);
gs.workflowFlush(current);
}

Regards,

Roopa

1 ACCEPTED SOLUTION

By the looks of it it should be simple to handle this.

Change this to before BR and remove/comment the current.update() line and this should fix it

 

Please mark my answer correct/helpful if it helped you solve your issue.

-Anurag

-Anurag

View solution in original post

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

 

Generally this happens of this or any other business rule which is part of the same transaction has current.update in it.

So can you please check if any other BR on the same table has current.update in it?

 

-Anurag

-Anurag

Community Alums
Not applicable

Hi Anurag,

 

Yes one BR is there find_real_file.png

 

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

// Add your code here
current.due_date="";
current.update();

})(current, previous);

 

Regards,

Roopa

Community Alums
Not applicable

i disabled it and it working fine like one notification going.

 

 

dont disable it, its probably there for a reason, see my last reply

-Anurag