How to show error message through OnSubmit client script? & Not show Order Confirmation Pop-up? and stop the request from Submitting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2021 12:57 AM
Hi,
I have a Catalog Item in which I have a On Submit Script which needs to show Error Message when the request is Submitted with Duplicate Variables.
But As soon as I submit the Error Message is shown but the Order Confirmation Pop-up shows up and the request can still be Check Out.
Which is eventually leading for the request to be submitted.
Same issue I am facing when I click on Add to Cart it shows the Error Message but the request eventually gets Submitted and the item is added to Cart.
Could you please provide a method where I can Show the error message and stop the request from Submitting -
- The Order Confirmation Pop up window should not show up.
- The Item should not be added to the Cart.
And only the Error Message should show up and the request is stopped from Submitting.
PFA Screenshots of the issue.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2021 01:29 AM
Hi Kunal
If you are only returning an error message then it will not stop from submitting the request .
you can add ' return false; ' in the if loop of your script to restrict the user from submitting the request .
Regards
Ashish Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2021 01:57 AM
Hi Ashish
I have added return false;
Still the request is not stopping from Submitting.The Error screenshots are attached to the question.
Below is the code.
function onSubmit()
{
var sn = g_form.getValue('sla_name');
var gd = new GlideAjax('DuplicateCheck');
gd.addParam('sysparm_name', 'checkDuplicate');
gd.addParam('sysparm_sysidvar1', sn);
gd.getXMLAnswer(function(answer)
{
if(answer=='Duplicate')
{
g_form.clearValue('sla_name');
g_form.addErrorMessage("This is a Duplicate Value");
return false;
}
});
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2021 02:26 AM