- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 05:38 AM
Hello all,
We have a before query business rule to filter ritm to be displayed. However, it doesnt seems work. What could i missed?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 06:28 AM
Hi @tsoct ,
It seems that there might be an issue with the way the encoded query is constructed
(function executeRule(current, previous /*null when async*/) {
var groups = j2js(gs.getUser().getMyGroups().toArray());
var groupsArray = groups.toString().split(',');
var groupsParentArray = groups.parent.toString().split(','); // Parent of my groups
var arr = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('parent', 'IN', groupsArray).addOrCondition('parent', 'IN', groupsParentArray);
gr.query();
while (gr.next()) {
arr.push(gr.getValue('sys_id'));
}
var arrayUtil = new global.ArrayUtil();
var finalArray = arrayUtil.concat(groupsArray, groupsParentArray, arr);
finalArray = arrayUtil.unique(finalArray);
var u = gs.getUserID(); // Get the sys_id value of the current user
var qc = "opened_by=" + u +
"^ORrequested_for=" + u +
"^ORwatch_listLIKE" + u +
"^ORassignment_groupIN" + finalArray.join(',');
current.addEncodedQuery(qc);
})(current, previous);
Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 06:28 AM
Hi @tsoct ,
It seems that there might be an issue with the way the encoded query is constructed
(function executeRule(current, previous /*null when async*/) {
var groups = j2js(gs.getUser().getMyGroups().toArray());
var groupsArray = groups.toString().split(',');
var groupsParentArray = groups.parent.toString().split(','); // Parent of my groups
var arr = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('parent', 'IN', groupsArray).addOrCondition('parent', 'IN', groupsParentArray);
gr.query();
while (gr.next()) {
arr.push(gr.getValue('sys_id'));
}
var arrayUtil = new global.ArrayUtil();
var finalArray = arrayUtil.concat(groupsArray, groupsParentArray, arr);
finalArray = arrayUtil.unique(finalArray);
var u = gs.getUserID(); // Get the sys_id value of the current user
var qc = "opened_by=" + u +
"^ORrequested_for=" + u +
"^ORwatch_listLIKE" + u +
"^ORassignment_groupIN" + finalArray.join(',');
current.addEncodedQuery(qc);
})(current, previous);
Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you
Shravan
Please mark this as helpful and correct answer, if this helps you