- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 06:54 AM
I had a dictionary entry on the assignment group filed on the Incident form, which was a simple reference qual of: type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ (type is empty or type is ITIL and active is true). Added a script for more functionality (see below) and in turned switched from simple to advanced for the use reference qualifier, and reference qual using the javascript:getAssignedToGroups().
I believe, in order to not loose the existing functionality, the simple type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ will need to be added to the script, most likely in the "section for case where assigned to is empty". What would the syntax be for type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ ?
// var getAssignedToGroups = Class.create();
// getAssignedToGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
// type: 'getAssignedToGroups'
// });
function getAssignedToGroups() {
var assignToGrpList = [];
var assignedTo = current.assigned_to;
// section for case where assigned to is empty
if (!assignedTo) {
gs.log("ggggg");
var grp77 = new GlideRecord("sys_user_group");
grp77.addQuery("assignment_group", 'true');
grp77.query();
while(grp77.next()) {
assignToGrpList = assignToGrpList + "," + grp77.sys_id;
}
assignToGrpList = assignToGrpList.toString();
//return "sys_idIN" + assignToGrpList;
return "sys_idIN" + assignToGrpList;
}
// section for case where assigned to is not empty
gs.log("sssssssss");
var grp = new GlideRecord("sys_user_grmember");
grp.addQuery("user", assignedTo);
grp.query();
while(grp.next()) {
gs.log(grp.group.name);
var grpsysid = grp.group.sys_id;
gs.log(grpsysid);
var grp88 = new GlideRecord("sys_user_group");
grp88.addQuery("sys_id", grpsysid);
grp88.addQuery("assignment_group", 'true');
grp88.query();
while(grp88.next()) {
gs.log("jjjjjjj");
var pare = grp88.parent;
var paresysid = grp88.parent.sys_id;
gs.log(pare);
gs.log(paresysid);
gs.log(grp88.parent.name);
assignToGrpList = assignToGrpList + "," + grp88.sys_id + "," + paresysid;
gs.log(assignToGrpList);
}
}
assignToGrpList = assignToGrpList.toString();
return "sys_idIN" + assignToGrpList;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 08:28 AM
Try javascript:'type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ^'+getAssignedToGroups()
Note the condition string is encapsulated in single quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 08:16 AM
The goal of the advanced javascript call accomplishes: Enter an "assigned to" name and it will then return the groups that person belongs to when clicking the magnifying glass of the assignment group field. The script does do that, but I had to take out existing functionality (in the reference qual box) that limited those groups to show only groups with a type of "null or ITIL" and active.
Goal now is to have the script goal and the original goal, for a SUPER BOWL GOAL.
After testing, it does not seem like I can have, in the reference qual box, the javascript call and the rest of the "null or ITIL" and active. Here is what I tried in the reference qual box:
First: javascript:getAssignedToGroups()^type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ
Second: type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ^javascript:getAssignedToGroups()
Neither worked ..... type a name in the "assigned to" and click in the assignment group field, and click magnifying glass returns all groups. So I am thinking I need to include it in the javascript. This is a script include. If there is a better way, that would be great also.
Incident form:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 08:28 AM
Try javascript:'type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ^'+getAssignedToGroups()
Note the condition string is encapsulated in single quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 10:16 AM
Abhinay, is that the total script or should it go in one of the sections or is it in addition to what is there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 10:18 AM
Nia, thanks for that thought. I was hoping the reference qual box would work and not have to code. It at first seemed to work, but as I tested more, I am getting some results that are not correct. I will retest just to make sure.