case visibility
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 08:04 AM
Hi experts,
We have a requirement.
Users are divided into two companies ABC and XYZ
1. Agents from ABC should see only cases belonging to these ABC company users.
2.Agents from XYZ should see only cases belonging to these XYZ company users.
3. There should be a global role that should access all the HRcase (both abc and xyz's)
What is the best approach for this.
TIA
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 10:27 AM
Hi @si21
A Business Rule for Query on the table works well. I've tested the following:
the condition above is:
gs.getSession().isInteractive() && !(gs.hasRole("admin") || gs.hasRole("user_admin"))
and the script is:
var usr = new GlideRecord('sys_user');
var curUser = gs.getUserID();
var userCompany = '';
var userList = [];
//gs.info('curUser = ' + curUser);
usr.addQuery('sys_id', curUser);
usr.query();
if (usr.next()) {
userCompany = usr.company.toString();
// gs.info("Found user: " + usr.name + ", company = " + userCompany);
}
// now get a list of users with the same company
var companyUsers = new GlideRecord('sys_user');
companyUsers.addQuery('company', userCompany);
companyUsers.query();
while (companyUsers.next()) {
userList.push(companyUsers.sys_id.toString());
}
gs.info('userList = ' + userList.toString());
current.addQuery("opened_by", "IN", userList.toString());
You could use ACL to limit, but seems a Before-Query BR is more common.