Have to add condition in reference qualifier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 12:26 AM
I have created this query ''javascript: if(current.variables.assign_to_self == 'Yes') new global.ITWorkRequest().assignmentGroup(current.variables.requested_for);'' in my reference qualifier for getting the groups in assignment group field.
Now I have to add the new condition like Active is True and type is Assignment or Type is itil in it.
(Query - active=true^typeLIKEb5e83f34b50521002747c7e9bebe4b30^ORtypeLIKE1cb8ab9bff500200158bffffffffff62)
Now can i do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 02:42 AM
Can you help to share the details in the assignmentGroup function? We may need to know what is returned from this line below.
new global.ITWorkRequest().assignmentGroup(current.variables.requested_for);
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 12:03 AM
Since your assignmentGroup function returns an encoded query, the approach suggested by Sandeep above should work for your case.
Or you can try to include the new query directly within the assignmentGroup function. Sample below.
assignmentGroup: function(userId) {
//add default query
var query = 'active=true^typeLIKEb5e83f34b50521002747c7e9bebe4b30^ORtypeLIKE1cb8ab9bff500200158bffffffffff62';
var arryVal = [];
var hasITILRole = this.hasITILRole(userId);
if (hasITILRole) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.query();
while (gr.next()) {
arryVal.push(gr.group.sys_id.toString());
}
} else {
var allGroups = [];
var cr = new GlideRecord('sys_user_group');
cr.query();
while (cr.next()) {
allGroups.push(cr.sys_id.toString());
}
arryVal = allGroups;
}
//return query with Syd Id
return query += '^sys_idIN' + arryVal.join(',');
},
There're a couple of things you may want to optimize as well.
- Try to avoid hard-coding the Sys Id in the code
- The Else block in your function is retrieving all the group Sys Id, that may significantly impact performance. If your intention is to return all groups, you may not need to perform a query, just simply return nothing.
Cheers,
Tai Vu
