Reference field with user selection linked to another reference field (similar to assignment group)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have added a 'assignment group' field to a form, this references the group table and is populated by a business rule.
Next I have added a 'template owner' field which references the user table, where I want user selection linked to the 'assignment group'. I can't use simple filters as the user table has no direct link to Group table.
I dont want to overcomplicated it & think there must be a straight forward way of doing this, i think there is something simple I am missing.
When a user is completing the form and they go to the 'template owner' field, they should be presented with a list of users who are assignment group members for whatever assignment group is populated in that field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hello @Kiran_25
If you open any incident, select any assignment group, then you will notice the assigned to will show only those users who are members of your selected assignment group. So, you can take that learning and implement the same. This means you just have to add "Assignment Group Column Label" in the Dependent under Dependent Field tab of Template Owner dictionary:
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @Kiran_25
You can achieve this with a simple dynamic reference qualifier on your template owner field. Because group members are stored in the many-to-many relationship table (sys_user_grmember) rather than the user table itself, a dynamic reference qualifier using an include script is the easiest way to solve this.
try this.
1. Create a script include
Set the Client callable checkbox to true
var getUserMembersByGroup = Class.create();
getUserMembersByGroup.prototype = {
initialize: function() {},
getGroupMembers: function(groupSysId) {
var userIds = [];
if (!groupSysId) return "sys_idIN";
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', groupSysId);
gr.query();
while (gr.next()) {
userIds.push(gr.user.toString());
}
return "sys_idIN" + userIds.join(",");
},
type: 'getUserMembersByGroup'
};
2.
Apply the Reference Qualifier on Your Field
- Open the form with your custom fields.
- Right-click the Template Owner field label and select Configure Dictionary.
- Scroll down to the Reference Specification tab.
- Set Use reference qualifier to Advanced.
- In the Reference qual field, enter
javascript:new getUserMembersByGroup().getGroupMembers(current.assignment_group);
- Click Save or Update.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti