Get the assigned to based on assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2023 04:23 AM
Hi,
OOB assignment group and assigned to fields are reference fields.
I have written a script where based on assignment group assigned to members to shown in the reference.
My requirement is the user should have the capability to select multiple groups as well as multiple assigned to.
I have created list type assignment group and assigned to fields respectively.
But when I select the assignment groups then in assigned to all the users are visible.
I want the dependancy of assignment group in assigned to.
But it is not happening.
Please suggest some ideas how to proceed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 03:23 AM
I have created a custom field in incident table.
as assigned_to field should be list one I created a custom field with type list reference to user table dependant on custom created assignment group which is also a list type reference to group table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 03:36 AM
if the field is custom for assignment group then you are using wrong field name
use correct field name for newly created assignment group
var assignmentGroups = current.u_assignment_group.toString();
var gr = new GlideRecord('sys_user_grmember'); //gr.addEncodedQuery('group=8a4dde73c6112278017a6a4baf547aa7^ORgroup=d625dccec0a8016700a222a0f7900d06');
gr.addQuery('group', 'IN', assignmentGroups);
gr.query();
var userIDs = [];
while (gr.next()) {
userIDs.push(gr.getValue('user'));
}
gs.log(userIDs);
return 'sys_idIN' + userIDs.join(',');
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 04:05 AM
Hi Ankur
I corrected it still the same.
I have selected 2 group names. when clicked on custom assigned to field I am seeing the list as empty.
is it something regarding the reference qualifier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 04:29 AM
you are not sharing script include
also the field name for group is u_group_assignment
so did you update that in script include function
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2023 06:30 AM
written two fuctions with parameter and without parameter to check but both are not showing the results.
var AssignmentGroups = Class.create();
AssignmentGroups.prototype = {
initialize: function() {},
groupMembers11: function() {
var assignmentGroups = current.u_group_assignment.toString().split(',');
var gr = new GlideRecord('sys_user_grmember');
//gr.addEncodedQuery('group=8a4dde73c6112278017a6a4baf547aa7^ORgroup=d625dccec0a8016700a222a0f7900d06');
gr.addQuery('group', 'IN', assignmentGroups);
gr.query();
var userIDs = [];
while (gr.next()) {
userIDs.push(gr.getValue('user')); }
return 'sys_idIN' + userIDs.join(',');
},
groupMembers: function(assignmentGroups) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', 'IN', assignmentGroups);
gr.query();
var userIDs = [];
while (gr.next()) {
userIDs.push(gr.getValue('user'));
}
var result = 'sys_idIN' + userIDs.join(',');
return result;
},
type: 'AssignmentGroups'
};