- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 02:27 PM
Hey all,
How would I go about displaying an error in the service portal on submit when the value in one field is also in another field?
I have a field with a list of groups to request access too. (group_name)
The other field holds all the groups the requested for user is a member of. (members_groups)
If they try to request a group (Group Name) the user is already a member of (Members Groups) on submit, I want an error to pop up so they have to fix it.
-or-
not display the groups already a member of in the (Group Name) field. Either way or both would be great knowledge for me.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 03:02 PM
If you want to go the first route you would use an onSubmit client script where you grab the values of both of those variables. The group name value will be a 32 character sys_id and the members groups value will be a comma-separated list of sys_ids. You would just check to see if the value of the members groups variable contains the value of the group name variable, then return false, add a message to the form, and clear out the value of the group name. I would try writing this script and then let us know if you run into any issues.
Your other option would be to use a reference qualifier on the group name field that doesn't allow the user to select a group they are a part of already. You can read more about reference qualifiers here: https://docs.servicenow.com/bundle/orlando-platform-administration/page/script/server-scripting/conc...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 03:02 PM
If you want to go the first route you would use an onSubmit client script where you grab the values of both of those variables. The group name value will be a 32 character sys_id and the members groups value will be a comma-separated list of sys_ids. You would just check to see if the value of the members groups variable contains the value of the group name variable, then return false, add a message to the form, and clear out the value of the group name. I would try writing this script and then let us know if you run into any issues.
Your other option would be to use a reference qualifier on the group name field that doesn't allow the user to select a group they are a part of already. You can read more about reference qualifiers here: https://docs.servicenow.com/bundle/orlando-platform-administration/page/script/server-scripting/conc...