- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2019 10:50 AM
I am trying to stop submission of a form if there are no recs in the related list.
i have an on submit client script with ajax call.
the ajax call returns the correct value,
but the submission is not halted.
the form closes and we go back to the list.
is it possible to do this via ajax?
if not, how?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2019 05:45 AM
I am able to accomplish my requirement in another way:
In the ui action (server) Submit button I determine if the submit can go forward.
If not,
I use gs.addInfoMessage() to add a message to form;
set a status to "failed";
action.setRedirectURL(current).
this does the job.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2019 10:54 AM
Check for whatever your GlideAjax is returning and return false, such as:
var val = result // result of GlideAjax
if(val == false) {
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2019 11:08 AM
it works if i do not have an ajax call.
if i have the return false within the response function it does not stop on the form, the form closes and we go back to the list.
would you please try this with an ajax script and let me know your result?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2019 11:09 AM
is there another way to see if the form has any records in the related list ... in a child table?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2019 11:20 AM
The following worked for me. You would obviously have to change your script include function to check the amount of records in that list and return a value to then check.
//Script include
var communityTest = Class.create();
communityTest.prototype = Object.extendsObject(AbstractAjaxProcessor, {
testFunction: function() {
return "false";
},
type: 'communityTest'
});
//Client Script
function onSubmit() {
var ga = new GlideAjax("communityTest");
ga.addParam("sysparm_name", "testFunction");
ga.getXMLWait();
if (ga.getAnswer() == 'false') {
g_form.addErrorMessage("Error")
return false;
}
}