We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Client script abort submission

Jake Sadler
Kilo Sage

I have the below client script that runs on the change table.I'm trying to stop the form from being submitted/saved when the user selects cancel but when I select cancel it still saves.

 

function onSubmit() {

var state = g_form.getValue('state');
var req = g_form.getValue('requested_by');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', req);
gr.query(myCallbackFunction);
gr.next();

function myCallbackFunction(gr) {
gr.next();
if (state == -94 || state == 50 && gr.company != g_form.getValue('company')) {
//state == -94 || state == 50 &&

var x = confirm('Requester does not belong to the identified Company. Are you sure you want to save?');

if (x == false) {

return false;

}

}


}

}

 

Any help would be much appreciated

1 ACCEPTED SOLUTION

Not applicable

I believe this covers the issue you are facing:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579

View solution in original post

1 REPLY 1

Not applicable

I believe this covers the issue you are facing:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579