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 Can your reduce the order of the client script so that it can run slightly earlier.

I tried it, still takes few seconds.

Is there a way to change it before the form loads?

shyamkumar VK
Kilo Patron

Hi @Snow Tomcal , 

here is some solution using on change client script based on the condition 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   var ab = g_form.getValue('u_select_value');
	if(ab == 'a'){
		this.jQuery('button').hide();
	}

   
}

 

Please see the below link.

1. https://community.servicenow.com/community?id=community_question&sys_id=1cd2e7fadb1c534c0e58fb651f96...

2. https://community.servicenow.com/community?id=community_question&sys_id=a31a8b69db5cdbc01dcaf3231f96...

3. https://community.servicenow.com/community?id=community_question&sys_id=a6a08365db98dbc01dcaf3231f96...

 

If this solution worked for you, please mark this as helpful & accept the solution as correct!
Regards,
Shyamkumar

 

 

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

Shyamkumar

It still takes a few seconds for the button to disappear.

Is there a way to change it before the form loads?

Ankur Bawiskar
Tera Patron
Tera Patron

@Snow Tomcal 

why to hide submit button? It requires DOM manipulation and is not recommended

just stop the form submission using return false in onSubmit client script.

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