How to get a Mandatory field in a Business Rule

Ereshkigal
Tera Contributor

Hi.

I have Mandatory set for some fields, but I want to change the content of the error message that is displayed.

This time, the UI Policy cannot be used due to complicated requirements.

So I want to use the Business Rule (On Before) to get the Mandatory field, what should I do?

Thank you!

 

2 REPLIES 2

Filipe Cruz
Kilo Sage
Kilo Sage

Hello Ereshkigal,

In your business rule you simply validate the content of the field and abort the action if the field is empty.
Something like:

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

    if (current.field_name == "") {
        gs.addErrorMessage("Field abc is empty!");
        current.setAbortAction(true);
        action.setRedirectURL(current);
    }

})(current, previous);

 

Hope this helps you!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

Kalaiarasan Pus
Giga Sage

I am guessing this is a duplicate question. If yes, I have tried to answer your other question - https://community.servicenow.com/community?id=community_question&sys_id=5ca0d0b0db03c150fd8d2b691396...