- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 07:46 AM
Hello Experts,
I created following client script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('AuditsAjaxInclude');
ga.addParam('sysparm_name', 'checkDates');
ga.addParam('sysparm_remark_nr', g_form.getUniqueValue());
ga.getXML(checkRemarks);
function checkRemarks(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer == 'false'){
alert('Estimated or Updated date are before Due date.');
return false;
}
}
}
script works as expected but user is still able to submit the form even with return false. What is the issue here?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 07:56 AM
Hi
the already proposed method getXMLWait() is NOT recommended and also doesn't work in Service Portals.
For your case, you need a special pattern. See the following article for the approach: https://community.servicenow.com/community?id=community_blog&sys_id=dc49feeadbdd7f0c54250b55ca96191d...
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 07:51 AM
Hi,
If you change this to getXMLWait then it will work.
Onsubmit script with getXML has conflicts.
Alternatively you can try a before insert or before update br that runs and checks this and aborts the action if needed.
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 07:56 AM
Hi
the already proposed method getXMLWait() is NOT recommended and also doesn't work in Service Portals.
For your case, you need a special pattern. See the following article for the approach: https://community.servicenow.com/community?id=community_blog&sys_id=dc49feeadbdd7f0c54250b55ca96191d...
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 09:30 PM
Hi
In case you think I was able to answer your question, I would be happy if you mark the appropriate response as "correct" so that the question will appear as resolved for other users who may have a similar question in the future.
If not, please tell me what you are still missing!
Many thanks & kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 07:37 PM
Hi,
Below solution is worked for me, please find the link below.
https://www.servicenow.com/community/developer-forum/using-return-false-in-glide-ajax/m-p/1567135