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!

4 REPLIES 4

vaishali231
Giga Guru

hey @mania 

 

add client script also 

function onSubmit() {
    var workNoteType = g_form.getValue('u_work_note_type');
    var emailNotification = g_form.getValue('u_email_noti_type');

    if (workNoteType === 'Customer Communication' && emailNotification === 'internal') {
        g_form.addErrorMessage(
            'Internal email notification is not allowed for Customer Communication.'
        );
        return false; // Stops save — NO redirect
    }
    return true;
}


*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.

Regards
Vaishali Singh

@vaishali231 

Thanks for responding

I want that in before business rule

Thanks!

hey @mania 

 

try this business rule 

(function executeRule(current, previous) {

    if (!gs.isInteractive()) {
        return;
    }

    var workNoteType = current.u_work_note_type + '';
    var emailNotification = current.u_email_noti_type + '';

    if (workNoteType == 'Customer Communication' && emailNotification == 'internal') {
        gs.addErrorMessage(gs.getProperty('case.worknote.customer.internal.error'));
        current.setAbortAction(true);
    }

})(current, previous);


*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.

Regards
Vaishali Singh

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