Tanushree Maiti
Tera Patron

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

  1. Open the form with your custom fields.
  2. Right-click the Template Owner field label and select Configure Dictionary.
  3. Scroll down to the Reference Specification tab.
  4. Set Use reference qualifier to Advanced.
  5. In the Reference qual field, enter

javascript:new getUserMembersByGroup().getGroupMembers(current.assignment_group);

  1. Click Save or Update.

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti