- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 04:05 AM
Hi all,
I need to know how to abort action in catalog client script based on the conditions when the catalog item is ordered during the on submit event. Ex if the condition is true i should make a request else if the condition is false i should not be able to make the request. I tried with return false; but it didn't work out well.
any help is really appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 06:00 AM
Try this...
function onSubmit() {
var name = g_form.getUniqueValue();
var ga = new GlideAjax('out_of_stock');
ga.addParam('sysparm_name', 'outOfStock');
ga.addParam('sysparm_field', name);
ga.getXMLWait();
var c_name = ga.getAnswer();
alert(c_name);
if (c_name != 'In stock') {
alert('this item is not in stock');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 05:18 AM
Hi Mark,
I am able to return the value from the script include to catalog client script but even though the condition is false the item is been requested.
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 05:24 AM
What does your code look like now? Are you using 'getXMLWait'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 05:30 AM
can you please tell me where should i mention that because when i used it before the Dosomething function, the function itself was not triggering.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 06:00 AM
Try this...
function onSubmit() {
var name = g_form.getUniqueValue();
var ga = new GlideAjax('out_of_stock');
ga.addParam('sysparm_name', 'outOfStock');
ga.addParam('sysparm_field', name);
ga.getXMLWait();
var c_name = ga.getAnswer();
alert(c_name);
if (c_name != 'In stock') {
alert('this item is not in stock');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2018 06:14 AM
Thank you so much this works like a charm