- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I am working on a requirement where I need some help to achieve the desired behavior in Employee Center.
Requirement:
All service catalogs (with key user restriction) should be visible to all end users.
However, only key users (members of a specific group) should be able to submit those catalogs.
If a non–key user tries to submit, they should see a message on Employee Center with a link to a report showing the allowed group members, so they understand why they cannot raise the request.
What I tried:
Created a Script Include that checks whether the currently logged-in user belongs to the key user group (using GlideRecord).
Created an onSubmit Client Script that calls this Script Include:
If true → allow submission.
If false → prevent submission and show a message.
Issue faced:
Since the Script Include is synchronous, the condition is not properly evaluated in time.
As a result, even if the user is not part of the key user group, they are still able to submit the request.
My ask:
What is the correct way to handle this scenario?
Is there any other best practice to validate group membership before submission in Employee Center?
Any suggestions or examples would be highly appreciated.
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
then do this
1) have a string variable and store the flag true/false based on logged in user member of that group
javascript: gs.getUser().isMemberOf('Group ABC');
2) hide this variable always using UI policy and keep this variable at the end so that it's never seen
3) then use onSubmit script and check value of this hidden variable and stop submission
function onSubmit() {
if (g_form.getValue('variableName').toString() == 'false') {
alert('Not allowed to submit');
return false;
}
}
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
3 weeks ago
Thanks, Ankur! Your suggested approach worked flawlessly. I appreciate you taking the time to share it and help others too.