check loggedin user role in ACL

soumya17
Tera Contributor

I created custom role 'X' when user with 'X' role logged in he needs to have write access to incidents that are opened by user with 'X' role.

For all other incidents created by different role, those records should be read-only..

Please help me to achieve this.?

 

Thanks

 

14 REPLIES 14

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this in the script of ACL, replace the X in the script with the role you have

 

if(gs.hasRole('X') & gs.getUser().getUserByID(current.created_by).getRoles().toString().indexOf('X') >-1)
{
answer= true;
}

 

 

-Anurag

Hi @Anurag Tripathi ,

 

I wrote this in write ACL incident*..but it didnt work..

as of now user can is able to edit only his own incidents(Caller=loggedin user) but he should be able to edit all incidents opened by custom role.

any other solution?

any other way ?

try this, there was one & less 

if(gs.hasRole('X') && gs.getUser().getUserByID(current.created_by).getRoles().toString().indexOf('X') >-1)
{
answer= true;
}

 

Also, use debug feature to see which ACL is returning false, you may have to modify that acl also along with this.

 

-Anurag

Harshal Aditya
Mega Sage
Mega Sage

Hi @soumya17 ,

 

Hope you are doing well.

 

You can update/create OOB incident read and write ACL and use code below

var answer;
if(gs.hasRole('x')){ 
answer = true;
 }
else 
answer = false;

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

 

Hi @Harshal Aditya

i tried this in write ACL incident*.

user can edit only his incidents but he should be able to edit all incidents opened by custom role.

Thanks