- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2025 11:17 PM
Hi,
I have defined a custom table which includes following 2 fields among others:
Field 1 -> reference to sys_user_group
Field 2 -> Choice field with dependent field as Field 1.name (i.e. referring to sys_user_group.name)
The requirement is whenever on Field 1, Group 1 is chosen, the choice field should display certain set of values and when Group 2 is chosen another set of values should be displayed. My choice values are defined against the sys_user_group.name values which is the dependent field.
In the form, whenever I chose a value for Field 1, the choice field field does not show any values. It looks like the matching of the choice values happens against the sysid of sys_user_group and not against the <name> of sys_user_group.
How to make this work. Please help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2025 12:50 AM
Hi @snehapatel
1)
- Create a new field (let’s call it group_name), type String, on your custom table.
- Mark it as calculated.
- In the dictionary record, add the calculation, something like:
// Assuming 'u_group' is your reference field to sys_user_group
if (u_group)
answer = u_group.name;
else
answer = '';
- Now, in your choice field dictionary entry, set the Dependent field = group_name.
- Define your choice dependencies against group_name values (the human-friendly group names).
2)
- You’d need to ensure groups are moved via update sets so they keep the same sys_id in all environments.
- This is fragile and not recommended — especially since sys_user_group often contains environment-specific groups.
- That’s why using names (via calculated field) or a custom mapping table is a safer and more portable approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2025 05:49 AM
I am not trying to showing the group name in 2nd field. The 2nd field is a choice field and the choice values are dependent on group name. For example if on 1st field group A is selected, 2nd field should show values 1,2,3. If group B is selected, then it should should show 4,5,6 and so on. Currently this is no happening as the matching happens against the sys_id and not group.name field even if the dependent field value is group.name.
Thanks,
Sneha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2025 05:51 AM
so you can write onChange client script and then add/remove options using g_form.addOption() and g_form.removeOption()
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
09-02-2025 11:32 PM
Hope you are doing good.
Did my reply answer your question?
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
09-03-2025 06:07 AM - edited 09-03-2025 06:07 AM
Thanks for your response
Using add or remove option will defy the purpose of configuring the choices and dependent field. So I would not go for it.
Thanks,
Sneha
