Get the assigned to based on assignment group

Pravallika9
Tera Expert

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

15 REPLIES 15

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

@Pravallika9 

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(',');

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur

I corrected it still the same.

Pravallika9_0-1680778984599.pngPravallika9_1-1680779023747.png

 

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.

@Pravallika9 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 

Pravallika9_0-1680785205003.png

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'
};