Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Oder now button hide

NannuSubhani Sh
Tera Contributor

Hi,

 

We have a variable in catalog item  which is look up select box(country) to location table in this we have 3 question choices(1.India,2.China,3.Japan) if user select 1.India  the order now button should be visible for remaining 2 values  we need to hide the order now button on service portal 

 

I have tried the below catalog On change client script it is not working kindly help on this how to achieve

 

alert('test');
var cntr = g_form.getValue('country');

if (cntr == 'India') {
$(sc_order_now_button).show();
$(sc_add_to_cart_button).show();
} else {
$(sc_order_now_button).hide();
$(sc_add_to_cart_button).hide();

 

1 ACCEPTED SOLUTION

@NannuSubhani Sh 

are you sure you are comparing correct value

Since you said it's a lookup select box then it will hold sysId; so you compare the sysId and not the label

var answer = g_form.getValue("country"); // variable type is look up select box of location table
if (answer != 'sysIdOfIndiaRecord') {
	var msg = getMessage("Request cannot be submitted due to the answer of User Details.");
	g_form.addErrorMessage(msg);
	return false;
}
}
Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Now its working thanks Ankur