Bootstrap FreeKB - ServiceNow - Hide the Order Now button
ServiceNow - Hide the Order Now button

Updated:   |  ServiceNow articles

When creating a Catalog Form in ServiceNow, by default, the Order Now button in the form will be visible.

 

You can hide the Order Now button using a Client Side Script. If you inspect the button in your web browser, you should see that the ID of the button is submit-btn. 

 

In ServiceNow, I start by selecting All Studio and then selected my app. Near the bottom of my Catalog Item app I select the Catalog Client Scripts tab and select New.

 

 

For example, the following Client Side Script can be used to hide the Order Now button when foo does not equal bar.

function onChange(control, oldValue, newValue, isLoading) {
   	if (isLoading || newValue == '') {
    	return;
	}

	var foo = g_form.getValue('foo');
	foo = foo.toString().trim();
   
	// if the foo variable does not contain the value bar display error message and hide the Submit button
	if (! /^(bar)$/.test(foo)) {
		g_form.addErrorMessage("foo does not equal bar");
		this.jQuery("#submit-btn").hide();
		return;		
	} else {
		// display the Submit button
		this.jQuery("#submit-btn").show();		
	}
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter d1f448 in the box below so that we can be sure you are a human.