- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2023 08:54 AM
Hello Guys
I want to restrict the user to see the case ,according to the region .
For example : I have six region
1. APAC
2. EURAF
3. INDIA
4.LAM
5. MENAT
6.NAM
In my case table I have total 22000 records , out of which India is having only 900. After Impersonating the india region user. I can see all the case table records .
But I want to restrict the other case region records in India region . I have created ACL.
Can Any one help me in code .
Thank you
Shivam
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2023 09:55 AM
Hello @Rai Shivam Ajay ,
You can refer below script in ACL
//If the user is trying to read a case record that doesn't relate to their Location.
var user = gs.getUserID();
var caseContact = current.contact; // Replace field with you want to compare from case
var userRegion;
var caseContactRegion;
var userGR = new GlideRecord('sys_user');
if(userGR.get('sys_id', user)){
userRegion = userGR.location.u_region;
}
var contactGR = new GlideRecord('sys_user');
if(contactGR.get('sys_id', caseContact)){
caseContactRegion = contactGR.location.u_region;
}
if (userRegion == caseContactRegion) {
answer = true;
}
else
{
answer = false;
}
Kindly mark correct and helpful if applicable

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2023 09:55 AM
Hello @Rai Shivam Ajay ,
You can refer below script in ACL
//If the user is trying to read a case record that doesn't relate to their Location.
var user = gs.getUserID();
var caseContact = current.contact; // Replace field with you want to compare from case
var userRegion;
var caseContactRegion;
var userGR = new GlideRecord('sys_user');
if(userGR.get('sys_id', user)){
userRegion = userGR.location.u_region;
}
var contactGR = new GlideRecord('sys_user');
if(contactGR.get('sys_id', caseContact)){
caseContactRegion = contactGR.location.u_region;
}
if (userRegion == caseContactRegion) {
answer = true;
}
else
{
answer = false;
}
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2023 07:31 AM