Populate the groups based on the user selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi ,
Requirement: 2 fields both are reference, 1st field is for user selection and 2nd field is for group autopopulate the user is part of.
Everytime different user selected, the group should be listed like that
Please suggest, what should be the field type if not correct,
not working for me,
Script Include:
-------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hello @paynityam
grp.addQuery('user', gs.getUserID()); // catalog = "Facility Site Server E2E Install " and returns Group name the PM is part of.
-
The above code always checks the currently logged-in user, not other users. So if anyone changes the user value, the validation still runs for the logged-in user only—not the selected user.
-
Make the Script Include server-side only (uncheck Client Callable) and use it in the Reference Qualifier of the Group field to dynamically filter groups based on the selected user:
javascript:new Your_Script_Include_Name().methodName(current.your_custom_user_field); -
Pass the selected custom user field value into the method and query the sys_user_grmember table to fetch groups for that user. Add the active=true condition to filter only active users/groups.
-
A Client Script is not required — the entire logic can be handled through the Reference Qualifier.
-
This can also be achieved using dependent fields, similar to OOB behavior between Assignment group and Assigned to on the Incident form
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @paynityam ,
If you wanted to auto populate all groups for the user, which are user part of then change
Field type as 'List'. Also change the query in script include to get proper users groups instead of logged in user groups.
If the client script is onchange of user then use below query: