Issue with redirection on case

mania
Tera Contributor

Hi,

 

I have created one business rule so when i am testing that on case form sometimes that is redirecting to another page so how to stop redirection 

Before/Inser, update

(function executeRule(current, previous /*null when async*/ ) {
    var workNoteType = current.u_work_note_type + ''; // Ensure string
    var emailNotification = current.u_email_noti_type + '';
          if (workNoteType == 'Customer Communication' && emailNotification == 'internal') {

            var msg1 = gs.getProperty('case.worknote.customer.internal.error');
            gs.addErrorMessage(msg1);
            current.setAbortAction(true);
            return;
        }
})(current, previous);

 

mania_0-1769771422428.png

Thanks!

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@mania 

business rule is on which table?

what's your actual business requirement?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

We have implemented a Before Insert/Update Business Rule to restrict the form when mismatched fields are selected and to display an error message. The error message is retrieved from a System Property, so that if the client wants to change the message in the future, they can do so easily without modifying the script.

However, during testing, when an invalid (mismatched) combination of fields is selected, the error message is displayed, but instead of remaining on the same case form, the system redirects to another random record/form.

Ensure that the error is shown on the same case form without any redirection.

Can you please help on this, it will be useful

(function executeRule(current, previous /*null when async*/ ) {
    var workNoteType = current.u_work_note_type + ''; // Ensure string
    var emailNotification = current.u_email_noti_type + '';
    var notifyCustomer = current.u_notify_customer == true || current.u_notify_customer == 'true';
    // 4.1 Customer Communication + Internal → Error
    if (workNoteType == 'Customer Communication' && emailNotification == 'internal') {
        var msg1 = gs.getProperty('case.worknote.customer.internal.error');
        gs.addErrorMessage(msg1);
        current.setAbortAction(true);
        return;
    }
  //4.3 External + Customer Communication + Notify Customer unchecked
    if (emailNotification == 'external' &&
        workNoteType == 'Customer Communication' &&
        !notifyCustomer) {
        gs.addErrorMessage(
            gs.getProperty('case.notify.customer.review.message')
        );
        current.setAbortAction(true);
        return;
    }
})(current, previous);
mania_0-1769783523465.png

 

Thanks!