- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 02:17 AM
Hi community,
I have a requirement where I have record producer which has two variable. Variable 1 the user has to select to the assignment group and in variable 2 they have to choose the assigned to. I need group members of assignment group selected in variable 1 to be shown to the users how do I do that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:33 AM
Variable 1 : Assignment Group [assignment_group] --> This will be a reference type variable which will refer to the Goup [sys_user_group] table.
Variable 2: Assigned to [assigned_to] --> This will be a 'List Collector' type field. This field will be refer to the User [sys_user] table.
Solution: In the advance reference qualifier of the variable 2 call a script include and pass the selected group's sys_id [current.variables.assignment_group]. Write the script in the script include to query the Group Member [sys_user_grmember] table with the selected group id and create an array of sys_ids of the users present against the group in the Group Member table. return the query as "sys_idIN"+array.join(",");
I hope this answer will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:33 AM
Variable 1 : Assignment Group [assignment_group] --> This will be a reference type variable which will refer to the Goup [sys_user_group] table.
Variable 2: Assigned to [assigned_to] --> This will be a 'List Collector' type field. This field will be refer to the User [sys_user] table.
Solution: In the advance reference qualifier of the variable 2 call a script include and pass the selected group's sys_id [current.variables.assignment_group]. Write the script in the script include to query the Group Member [sys_user_grmember] table with the selected group id and create an array of sys_ids of the users present against the group in the Group Member table. return the query as "sys_idIN"+array.join(",");
I hope this answer will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 03:34 AM
Variable 2 can be a reference type field it is up to your need if you want to select 1 user or multiple user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 04:04 AM - edited 04-25-2024 04:06 AM
Hi ProdiptoL,
I have created the script include and passed it to the reference qualifier
var <scriptIncludeName> = Class.create();
<scriptIncludeName>.prototype = {
initialize: function refqualassignedto() {
var group = current.variables.assignment_group; // your assignment group variable name
var user_array = [];
if (group != '') {
var getMembers = new GlideRecord('sys_user_grmember');
getMembers.addQuery('group', group);
getMembers.query();
while (getMembers.next())
{
user_array.push(getMembers.user);
}
return 'sys_idIN' + user_array.toString();
} else {
return 'active=true';
}
},
type: '<scriptIncludeName>'
};
and the reference qualifier looks like
javascript:<scriptIncludeName>();
does it need variable attribute?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 04:09 AM
Reference Qualifier= javascript:new <scriptIncludeName>().refqualassignedto();
script include correction:
user_array.push(getMembers.getValue("user"));
