- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 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