javascript:getMyGroups() not working in business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2015 06:03 AM
Hi All,
current.addQuery('assignment_group','javascript:getMyGroups()'); is not working, Please let me know what is exactly wrong in this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2015 06:15 AM
tried with 'javascript:gs.getMyGroups()' as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2015 06:32 AM
Hello Dhathri,
javascript:getMyGroups() returns a list of group(s), the logged in user is part of. The list may contain more than one group.
How can you query the assignment_group field with a list of groups?
You need to split the list with ",". Then store it in a array and write query like :
current.addQuery('assignment_group',arr[i]);
assuming arr is the array variable and variable "i" is for indexing.
Hope, you would be able to rectify the issue now.
Please mark this reply correct/helpful if it answers your query.
Thanks,
Subhankar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2015 07:10 AM
var secGroupStr = gs.getProperty('takeda.incident.securityGroup');
var secGroups = secGroupStr.split(',');
var hideGroups = [];
for (var i = 0; i < secGroups.length; i++) {
if (!gs.getUser().isMemberOf(secGroups[i])) {
hideGroups.push(secGroups[i]);
}
}
var sec_query;
//Hide Security group incidents unless you are the caller or group member
//gs.log('JDM - ' + hideGroups.join(','));
if (hideGroups.length > 0 && !gs.hasRole('admin') &&
!gs.hasRole('field_services') && gs.isInteractive()) {
var u = gs.getUserID();
current.addQuery('assignment_group','NOT IN',hideGroups.join(',')).addOrCondition('assignment_group','');
//current.addQuery("caller_id", u).addOrCondition("opened_by", u);
} else if (hideGroups.length > 0 && !gs.hasRole('admin') &&
gs.hasRole('field_services') && gs.isInteractive()) {
var u = gs.getUserID();
current.addQuery('assignment_group','NOT IN',hideGroups.join(','));
//current.addOrCondition("caller_id", u).addOrCondition("opened_by", u);
current.addQuery('assignment_group','javascript:getMyGroups()');
} else if (gs.hasRole('field_services') && !gs.hasRole('admin') && gs.isInteractive()) {
//Only show field services their groups work.
current.addQuery('assignment_group','javascript:getMyGroups()');
current.addQuery('assignment_group','!=','');
}
if (!gs.hasRole("itil") && !gs.hasRole("incident") && !gs.hasRole("field_services") && !gs.hasRole("problem") && !gs.hasRole("change") && !gs.hasRole("knowledge") && !gs.hasRole("release_v2_admin") && gs.isInteractive()) {
var u = gs.getUserID();
var qc = current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u);
gs.print("query restricted to user: " + u);
}
-----
This is the Business rule existing, Could you please help me to correct this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2015 07:13 AM
Inside a BR, you don't need the 'javascript:' prefix.
just gs.getMyGroups()
(i would also right that value to a log and see what it is giving you, as it may not be in the proper format to use)