- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2019 06:00 AM
I have a client side script that is supposed to validate some values on the catalog item page during Submit event, and to stop submit if it fails. The problem comes in during validation because Ajax call is also involved there, and we all know that we can't stop submit from within Ajax callback. The solution for this frequent issue is described here: https://snprotips.com/blog/2018/10/19/synchronous-lite-onsubmit-catalogclient-scripts . Basically a flag is set inside the Ajax callback and the form gets re-submitted if valid, something like this:
function onSubmit() {
if (getValueOfTheFlag('valid')) {
return true;
}
var gAjax = new GlideAjax('MyUtil');
gAjax.getXML(MyCallBack);
return false;
}
function MyBallBack(response) {
if(response.success) {
setValueOfTheFlag('valid', true);
g_form.submit();
} else {
setValueOfTheFlag('valid', false);
}
}
The problematic line here is g_form.submit() call, which is supposed to resubmit the form after validation, however when that line is executed, I get this error message:
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2019 11:15 AM
Thank you, but I just wanted to re-submit the form in order to keep the same UI experience. Turns out g_form.getControl('order_now_button').click() was all I need. It works great.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2019 09:01 AM
You need to use cart API to submit catalog item and call this cart API from your script include.
This will submit catalog item.
Also, you can use OOB service catalog API to submit order using catalog item.
You can call this service catalog API from your script include.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2019 11:15 AM
Thank you, but I just wanted to re-submit the form in order to keep the same UI experience. Turns out g_form.getControl('order_now_button').click() was all I need. It works great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2020 11:17 PM
g_form.getControl('order_now_button').click(); is not working for me. Can you give me an alternative. g_form.submit is working for portal but not for catalog item CMS. I want some alternative of g_form.submit which works in both.
Here is the callback function. Please help
function HelloWorldParse(response) {
if(ans1 =="success")
{
g_form.setValue('check_flag', 'true');
g_form.getControl('order_now_button').click();
}
else{
alert("No field values have changed");
g_form.clearValue('application_name');
g_form.clearValue('type_of_operation');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 03:45 AM
Thanks thats all what I need too 🙂