Restrict assignment group based on Category

KrishnaMoorthyH
Tera Contributor

Hi ,

 

I wanted to restrict assignment group values(display any 2 groups) when the incident category is "Inquiry/help" and "software". How this can be achieved through script include? I want to call the script include from override reference qualifier. Thank you.

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

Your reference qualifier override would look like this:

BradBowman_0-1696787400157.png

The Client callable Script Include would do a GlideRecord query on the sys_user_group table if the category (argument in function, passed in from reference qualifier) value is one of your two choices.  You can use setLimit to only return 2 records if you truly mean any 2 groups, or whatever your criteria is, pushing each sys_id to an array.  Return the array like this:

return 'sys_idIN' +  grpArr.join(',');

 

Anand Kumar P
Giga Patron
Giga Patron

Hi @KrishnaMoorthyH ,
You can write script include like below.

 

 

 

var AssignmentGroupFilter = Class.create();
AssignmentGroupFilter.prototype = {
    initialize: function() {},
    filterAssignmentGroups: function(category) {
        var validAssignmentGroups = [];
        if (category === 'Inquiry/help' || category === 'Software') {
    var groupGR = new GlideRecord('sys_user_group');
groupGR.addEncodedQuery('copy2group_sys_id_queryfrom_tableand copy');
    groupGR.setLimit(2); 
    groupGR.query();
        while (groupGR.next()) {
            validAssignmentGroups.push(groupGR.getUniqueValue());
        }
    }
    return 'sys_idIN'+validAssignmentGroups.join(',');
    },
    type: 'AssignmentGroupFilter'
};

 

 

 

In Reference Specification Tab-Reference qualifier in assignment group field add below script-

 

 

 

javascript : new AssignmentGroupFilter().filterAssignmentGroups(current.category);

 

 

 

 Please mark it as Solution Proposed and Helpful if it works for you.

Thanks,

Anand