- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 09:41 AM
The OOB Dynamic Filter pulls in Parent groups. I inserted new Dynamic Filter Option and the Business Rule that it references. Is there a way to modify the Business Rule so that it doesn't pull in the Parent Groups. Only want the script to pulll in groups that have a "Type" that contains Incident, Task, or Change. All of the parent groups don't have a "Type" value.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 02:17 PM
Sorry Mike just notice you have your getMyAssignments declared on the prototype. You are going to want to move it of the prototype definition so you can call it directly without creating a UserUtil object:
var UserUtil = Class.create();
UserUtil.prototype = {
initialize: function() {
},
type: 'UserUtil'
};
UserUtil.getMyAssignmentGroups = function(userID){
var queryString = "user=" + userID + "^group.typeLIKE52c230cd21412400abe30817dc6fb00f^ORtypeLIKEa59723f0213d6800abe30817dc6fb09d^ORtypeLIKE2da8677721056400abe30817dc6fb0fe";
var groupsArray = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
groupsArray.push(gr.group.toString());
}
return groupsArray;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 01:08 PM
Group type is a reference to sys_user_group_type, you will need to pass the sys_ids of the records that correspond to the incident, change, and task group types
So in the left nav filter enter sys_user_group_type.LIST to bring up the list view of the group type table. Right click the rows corresponding to the above and click copy sys_id, then replace the text values in your query string with the sys_ids:
"^group.typeLIKEIncident group type record sys_id^ORtypeLIKELocal group type record sys_id^ORtypeLIKEChange group type record sys_id";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 01:53 PM
Yes, I had tried using the sys_id's previously with same result. Just added them to the SI again and still returning empty
var UserUtil = Class.create();
UserUtil.prototype = {
initialize: function() {
},
UserUtil:getMyAssignmentGroups = function(userID){
var i = 0;
var queryString = "user=" + userID + "^group.typeLIKE52c230cd21412400abe30817dc6fb00f^ORtypeLIKEa59723f0213d6800abe30817dc6fb09d^ORtypeLIKE2da8677721056400abe30817dc6fb0fe";
var groupsArray = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
groupsArray.push(gr.group.toString());
}
return groupsArray;
},
type: 'UserUtil'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 02:00 PM
Ok, try pulling up the sys_user_grmember list and build your query in the filter, add three group type contains conditions for the sys_ids you are targeting. Do you get back rows that correspond to the query?
Also, it looks like in your function definition UserUtil:getMyAssignmentGroups you have a colon between UserUtil and getMyAssignmentGroups....should be a period
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 02:17 PM
Sorry Mike just notice you have your getMyAssignments declared on the prototype. You are going to want to move it of the prototype definition so you can call it directly without creating a UserUtil object:
var UserUtil = Class.create();
UserUtil.prototype = {
initialize: function() {
},
type: 'UserUtil'
};
UserUtil.getMyAssignmentGroups = function(userID){
var queryString = "user=" + userID + "^group.typeLIKE52c230cd21412400abe30817dc6fb00f^ORtypeLIKEa59723f0213d6800abe30817dc6fb09d^ORtypeLIKE2da8677721056400abe30817dc6fb0fe";
var groupsArray = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
groupsArray.push(gr.group.toString());
}
return groupsArray;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 03:00 PM
Thank you Bob!!. Fixing the SI prototype declaration did it. I also needed to use group.type instead of just type n the queryString to pull in the other Types. Thanks for all your help. Much appreciated!
var queryString = "user=" + userID + "^group.typeLIKE52c230cd21412400abe30817dc6fb00f^ORgroup.typeLIKEa59723f0213d6800abe30817dc6fb09d^ORgroup.typeLIKE2da8677721056400abe30817dc6fb0fe"
Here is the revised Script Includes:
var UserUtil = Class.create();
UserUtil.prototype = {
initialize: function() {
},
type: 'UserUtil'
};
UserUtil.getMyAssignmentGroups = function(userID){
var i = 0;
var queryString = "user=" + userID + "^group.typeLIKE52c230cd21412400abe30817dc6fb00f^ORgroup.typeLIKEa59723f0213d6800abe30817dc6fb09d^ORgroup.typeLIKE2da8677721056400abe30817dc6fb0fe";
var groupsArray = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
groupsArray.push(gr.group.toString());
}
return groupsArray;
};