- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 09:08 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 10:30 AM
I believe this covers the issue you are facing:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 10:30 AM
I believe this covers the issue you are facing:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579