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.

Hide The Submit Button on a Catalog Client Script

Snow Tomcal
Tera Expert

Hi All,

I want to hide the submit button on a specific catalog item based on a condition.

I tried using a UI policy but it's executed after the page has loaded. Because the page is heavy, it takes a second and the user can see the submit button before it disappears.  Is there any way to hide the button before the page loads? 

Thanks 🙂

16 REPLIES 16

@Snow Tomcal 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Can you tell me how you can stop the form from submission if the value of a variable is XYZ?

We are trying to either hide the submit button or prevent the form from being submitted if "Religion" is selected on the "type of request" variable. Instead, we are providing them with a link to submit this on another site. 

@Dario Idrovo1 , 

You need to use -    return false; on Submit Client Script if you want to abort submission if your Validation Fails

 

Something like this 

 

var value = g_form.getValue(' XYZ');

if(value=='region'){

alert("you cannot select region in xyz variable)

return false;

Regards.

Shyamkumar

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

@shyamkumar VK 

That is what I have, but it doesn't work. Here is the code I had written.

function onSubmit() {
   //Type appropriate comment here, and begin script below
   var accomm = g_form.getValue('u_accommodation_type');
    if (accomm == 'religious') {
        g_form.addInfoMessage('Please click here to submit a religious accommodation request.');
		return false;
    }
}

@Dario Idrovo1 , Script looks good , can you please check if your Passing Correct Backend values in the Script , I have added alerts to the Script can you please check if alerts getting triggered?

 

function onSubmit() {
   //Type appropriate comment here, and begin script below
   var accomm = g_form.getValue('u_accommodation_type');
alert(accomm);
    if (accomm == 'religious') {
        g_form.addInfoMessage('Please click here to submit a religious accommodation request.');
		return false;
    }
}

 

Regards.

Shyamkumar

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar