What is the script syntax for: type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ

paw2
Tera Expert

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         ?

find_real_file.png

// 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;

}

1 ACCEPTED SOLUTION

Try javascript:'type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ^'+getAssignedToGroups()


Note the condition string is encapsulated in single quotes.


View solution in original post

9 REPLIES 9

paw2
Tera Expert

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:


find_real_file.png


Try javascript:'type=null^ORtype=1cb8ab9bff500200158bffffffffff62^active=true^EQ^'+getAssignedToGroups()


Note the condition string is encapsulated in single quotes.


paw2
Tera Expert

Abhinay,   is that the total script or should it go in one of the sections or is it in addition to what is there?


paw2
Tera Expert

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.