Regarding the user restriction in case table

Rai Shivam Ajay
Tera Contributor

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

1 ACCEPTED SOLUTION

Chetan Mahajan
Kilo Sage
Kilo Sage

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

View solution in original post

2 REPLIES 2

Chetan Mahajan
Kilo Sage
Kilo Sage

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

Rai Shivam Ajay
Tera Contributor

Hello Chetan,
When I am saving after writing a script in ACL . I am getting the error . As below I am attaching the screen shot.
Thank you
Shivam Rai