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 02:19 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 09:52 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 10:13 AM
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
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 09:53 AM
@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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 03:37 PM
@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
Regards,
Shyamkumar
