Business rule abort action

Nisha B
Tera Expert

Hello All,

 

I have a before update business rule on incident table which checks if assignment group is 'XYZ' and Knowledge Record is not empty and status changes to Resolved .

So if condition matches it will abort the submission using action and show error message.

 

But now what is happening is ,  if we are setting the incident status value to resolve from pending on hold using other business rule then this also triggers as soon as status changes to resolve and it will not allow to update the status to resolve.

So how I can override this business rule if status changes to resolve and for assignment group 'xyz' and knowledge article is empty , 

this means this business rule should not work for condition when status is pending and substatus is onhold irrespective of KB is knowledge record filed is empty or not empty.

Any suggestion will helpful.

 

Thanks 

1 ACCEPTED SOLUTION

Hello Sagar,

 

I modify the condition as below and it is working fine now-

 

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

    // Add your code here
    if (current.state != previous.state) {
var previousState = previous.incident_state.getDisplayValue();
var subSt = previous.u_sub_status.getDisplayValue();

if (previous.incident_state == -5 && previous.u_sub_status == "On hold") {

return;
}   
else if (current.incident_state== 6) {

gs.addErrorMessage('Error: Please attach atleast one Knowledge article to resolve this incident.');
current.setAbortAction(true);
return;
}
}


})(current, previous);

View solution in original post

3 REPLIES 3

Sagar Pagar
Tera Patron

Hi @Nisha B,

I guess there is condition conflicts with both business rules. It is possible to remove the condition conflicts and check once.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Hello Sagar,

 

thanks for reply.

actually through first business rule setting status to resolve if incident status is in pending onhold for more the 5 days,

and other business is running as soon as the status changes to Resolve .I am not getting how to stop this business rule only if  the status is pending on hold

Hello Sagar,

 

I modify the condition as below and it is working fine now-

 

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

    // Add your code here
    if (current.state != previous.state) {
var previousState = previous.incident_state.getDisplayValue();
var subSt = previous.u_sub_status.getDisplayValue();

if (previous.incident_state == -5 && previous.u_sub_status == "On hold") {

return;
}   
else if (current.incident_state== 6) {

gs.addErrorMessage('Error: Please attach atleast one Knowledge article to resolve this incident.');
current.setAbortAction(true);
return;
}
}


})(current, previous);