Hide The Submit Button on a Catalog Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 01:01 AM
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 01:16 AM
@Snow Tomcal Can your reduce the order of the client script so that it can run slightly earlier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 01:44 AM
I tried it, still takes few seconds.
Is there a way to change it before the form loads?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 01:04 AM
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.
If this solution worked for you, please mark this as helpful & accept the solution as correct!
Regards,
Shyamkumar
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 01:43 AM
It still takes a few seconds for the button to disappear.
Is there a way to change it before the form loads?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 02:02 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
