return false in catalog client script

sanju
Kilo Contributor

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.

1 ACCEPTED SOLUTION

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;
    }
}

 

View solution in original post

12 REPLIES 12

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

What does your code look like now?  Are you using 'getXMLWait'?

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.

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;
    }
}

 

Thank you so much this works like a charm