- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
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
Tuesday
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
Monday
@snehapatel
The UI allows you to pick subfields from the referenced table, but the dependency engine ignores them. Matching always happens on the stored value (the sys_id), because that’s what’s efficient and guaranteed to exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Thanks for your response. It was very helpful. I have 2 more queries :
1) For the option you provided (below), could you please tell how to achieve this using dictionary attribute.
Alternative approach (if sys_ids are not manageable)
- Add a Dictionary attribute or a calculated field that stores the name of the selected group from the reference.
- Use that field as the dependent field for your choices.
2) Second question, if the recommended option is 1 using sysid, how do you manage hen moving configurations from one environment to environment. Sysid would always vary.
Thaks,
Sneha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
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
Wednesday
Many thanks for your response. For the solution 1 in your response, it only works when you save the record in database after entering the value for field 1. For dynamic behavior I have added onChange script and it works. Thanks for your help.
Thanks,
Sneha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
2nd field is choice then why not use advanced ref qualifier?
Also what's the point in showing Group Name in 2nd field when you already know the Group Name from 1st field which is reference type.
what's your actual business requirement?
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