Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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