Script Include to filter assignment group

fanare
Giga Contributor

Hello,

I'm trying to filter the reference available on the assignment group.

I was reading about reference qualifiers but I can't seem to add a condition to them. What i'm trying to do is, whenever an incident has 'test company' as the company, it will filter the assignment group to a specific group based to that company. I established a reference between the two tables, but I was wondering what would be the best approach. I'm thinking its probably a script include, but any insight would be helpful. Thank you.

6 REPLIES 6

Alikutty A
Tera Sage

Hello,

Can you further clarify your requirement with a sample or screenshot? Based on my understanding, If you select a specific company on a form then a specific group on the company should be populated as the Assignment group? 

So lets say you have a company : 'tech' company which has 4 assignment groups associated with it. 'west tech' , 'north tech', 'south tech', 'east tech'. You want the assignment group field to only ever show those groups whenever the company field is set to 'tech' company.

So whenever you try to assign an assignment group on the form and have 'tech' company selected (as the company), you should only be able to choose from the four groups (north,east,south,west). 

 

I'm sorry if i'm not being clear. I dont have any other examples to go off of.

If the 4 groups are mapped to the company in the same table, Then you can add an advanced reference qualifier on your Assignment group field that says

javascript:'sys_idIN'+current.company.u_group_1+','+current.company.u_group_2+','+current.company.u_group_3+','+current.company.u_group_4

Here company is your field name on the form

and u_grouo_x are the field names of the groups related to your company

OR

If they are on a separate table relation to the company then you need to write a script includes which returns the 4 groups in the same format as above with the sys_id and call it from the advanced reference qualifier as

javascript: new YourScriptIncludeName().getGroups(current.company);

Thanks!

This is what I have this far:

var BackfillAssignmentGroup = Class.create();
BackfillAssignmentGroup.prototype = {
initialize: function() {
},

BackfillAssignmentGroup:function() {
var gp = '';
var company = current.company;
var domain = current.domain;

if(!company)
return;
var grp = new GlideRecord('sys_user_group');
//grp.addQuery('u_company',company);
grp.addQuery('company', company);
grp.query();
while(grp.next()) {
if (gp.length > 0) {
gp += (',' + grp.getUniqueValue());
}
else {
gp = grp.getUniqueValue();
}
}
return 'sys_idIN' + gp;
},
type: 'BackfillAssignmentGroup'
};

 

I realized that I need to filter by domain as well. If the domain on the company matches the assignment group. I'm trying to figure out how to compare them.