Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Duplicate Error Message on setAbortAction(true)

Ghazali
Tera Contributor

Hi,

I am trying to stop users from being able to change a field and when someone tries to change it, an error message should come up. I wrote a BR for it but I the error message was coming 2 times instead of 1. So assuming the problem was with my instances configuration, I requested a fresh instance and wrote a business rule for incident table which runs before a record is updated. Here's the script:

 

 

(function executeRule(current, previous /*null when async*/) {
    if (current.contact_type != previous.contact_type) {
        gs.addErrorMessage("Info not saved.");
        current.setAbortAction(true);
    }
})(current, previous);



I have tried adding gs.flushMessages() before throwing the error message but that solution didn't work. I am still getting the error message twice.

 


Ghazali_0-1708283473875.png

 

 

NOTE: This only happens if i open the incident table from filter navigator and try changing the field from list view, instead if i right click on incident and choose open in new tab and then do the same then i get only 1 error message as it should come.

Regards,
Ghazali
1 ACCEPTED SOLUTION

Thanks @Ghazali,

 

I remember seeing this in the past and it is a known issue. The fix is available in Vancouver Patch 6, please see the details here

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1588238

 

Thanks

View solution in original post

3 REPLIES 3

James Chun
Kilo Patron

Hi @Ghazali,

 

Can you please provide a screenshot of the 'When to run' tab of the Business Rule?

 

Thanks

@James Chun  Thanks for the prompt reply, here is a screenshot of the "When to run" tab :

Ghazali_0-1708286781930.png

 

Regards,
Ghazali

Thanks @Ghazali,

 

I remember seeing this in the past and it is a known issue. The fix is available in Vancouver Patch 6, please see the details here

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1588238

 

Thanks