
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 07:35 AM - edited 02-16-2023 12:00 AM
Hello,
My requirement is to restrict submit option if a user is part of a certain group.
The user needs to access the catalog item and should be able to see all the variables in it (which are set to read only) but if submit button is clicked, an error should appear and the submission shouldn't be allowed.
Things I have tried:
Script include:
Client script onSubmit:
1st version:
2nd version:
I have tried with XMLWait as well but the method is no longer used.
Thank you.
Elena
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 01:28 AM
Let me know what do you guys think, I managed to solve it this way:
Script include:
Client script:
Tested it both ways(user part of group, user that isn't part of the group) and it seems that it works as expected.
Thank you for all the ideas, you guys are amazing!
Have a great day,
Elena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 07:58 AM
Hi @Elena Pomana - As mentioned by Allen you need to pass the user info from GlideAjax code to Script Include.
please refer this for more info link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 08:06 AM
you are using asynchronous GlideAjax in onSubmit
So by the time the ajax function validates via script; 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
OR
2) you can write onChange catalog client script on your user variable and pass the user details and then check by querying sys_user_grmember with this user and your group if record is present or not
If present then show error on variable
This will ensure that the form gets submitted when the error is not there i.e. the validation is passed
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
02-16-2023 01:28 AM
Let me know what do you guys think, I managed to solve it this way:
Script include:
Client script:
Tested it both ways(user part of group, user that isn't part of the group) and it seems that it works as expected.
Thank you for all the ideas, you guys are amazing!
Have a great day,
Elena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 01:50 AM
Glad to know.
Please close the thread by marking appropriate response as correct 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
02-16-2023 04:56 AM
Did you verify the script worked for both Native + Portal view?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader