- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2021 04:14 AM
How to disable the submit button in the catalog form if the variable choice option is selected as Disagree
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2021 04:56 AM
Why not use onSubmit catalog client script and if the variable is Disagree stop form submission
function onSubmit(){
if(g_form.getValue('variable') == 'Disagree'){
alert('Not allowed');
return false;
}
}
you need to write onChange catalog client script on that variable
Show/hide the button using DOM
Note: DOM is not recommended approach
check this link for help
Show/Hide Submit button on Catalog Item
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2023 07:18 AM
Can you please raise a new question for this as this is an older thread?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2023 07:23 AM
are you saying you don't want users from particular group to submit the request?
If yes then why not use User criteria with scripting and hide the catalog item itself if logged in user belongs to that group. then associate this user criteria for your catalog item
you are using asynchronous GlideAjax in onSubmit
So by the time the ajax function checks the form gets submitted as it won't wait as it's async
Here are couple of approaches
1) use onSubmit with synchronous GlideAjax; this is somewhat tricky and you need to check below links for solution and enhance as per your case
https://snprotips.com/blog/2018/10/19/synchronous-lite-onsubmit-catalogclient-scripts
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2023 07:35 AM
I have tried both ways, the form still gets submitted.
Here's the link to the new topic: https://www.servicenow.com/community/developer-forum/restrict-user-to-submit-form-via-onsubmit-clien...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2023 07:01 AM
Hi Elena,
Asynchronous call doesn't work on "OnSubmit" client script.
Please try and use "getXMLWait".
Thanks,
Soujanya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2021 05:20 AM
Thanks all for your support.