Script Include to filter assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 09:51 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 09:56 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 10:41 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 10:49 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2018 08:25 AM
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.