How script include dynamically works on different task type thru Reference Qualifier

Avee90
Tera Contributor

Hello Folks, 

     I've a requirement to show only groups with users on INC, Problem, Change, RITM and their child tables in assignment group. Initially, I've tried with task table but Problem and change are using two different dictionary overrides(For change: Group type is  change group type and For Problem: group type is  Problem group type) rest tables are using same reference qual( group type is assignment group).

 The script include is working fine to show only groups with users. But the challenge here is client is asking me to use a single function, in that use variables to store task types(Change, Problem, INC and RITM) and pass these as parameters within in the function. So, this has to be dynamically applies when user open INC, PR, RITM and CR table's assignment group field. Is this achievable or should I use different function. If this works can  help me the script and Ref Qual. I providing the script include.

Script Include:

var groupsWithUsers = Class.create();
groupsWithUsers.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getGroups: function() {
       // gs.info('linenumber 4');
        var myGroups = [];
        var grGroup = new GlideRecord("sys_user_group");
        grGroup.addActiveQuery();
        grGroup.query();
        while (grGroup.next()) {
            var grGroupMember = new GlideRecord("sys_user_grmember");
            grGroupMember.addQuery("group", grGroup.sys_id.toString());
            grGroupMember.query();
            //gs.info('linenumber 13');
            if (grGroupMember.next()) {
                myGroups.push(grGroup.getUniqueValue());
                //count++;
            }
        }
        var groups = 'sys_idIN' + myGroups.toString();
        //gs.info('linenumber' + myGroups);
       
        return groups;
    },
    type: 'groupsWithUsers'
});



3 REPLIES 3

Brian Lancaster
Tera Sage

Advanced reference qualifier with the following code.

javascript: new groupsWithUsers().getGroups()

Hello Brian,

   Thanks for the response. I'm using that ref qual already but I need an dynamic ref qual run INC, PR, CR and RITM using single function passing the task types as parameters.

Thanks,
Avee 

I don't understand. This is already a single function that you would call for each of these. Task type would not matter unless you are returning a certain set of group depending on the task type.

 

One other thing I will mention is that this is not the correct way to go about this. You should either have the group setup with a group type that are for inc, problem, cr, and RITM and then set the dictionary override on all these task type to group type is itil for example. Doing it by only showing groups that have members seems to be just hiding the fact that you don't have a good process around group management.