ACL Script

Community Alums
Not applicable
  • Modify the existing “write” ACL on the Provider table to allow ONLY users from the "Owned by group" to edit the Provider records

  • Owned by group has members only the members can change the provider.

My Script:

 

var result = false;


var list = current.owned_by_group.toString().split(',');


for (var i = 0; i < list.length; i++) {


var grp = new GlideRecord('sys_user_group');


grp.get(list[i]);


if (gs.getUser().isMemberOf(grp.getDisplayValue())){
result = true;

break;


}
}

 

 

answer = result;

 

1 ACCEPTED SOLUTION

Taha Habib
Tera Guru

Hello Abdul, I believe the last if condition alone is enough to complete your requirement. I am assuming you have a group called "owned by group", which has some users in it, and you want only those users to write to the record. I have replicated the requirement in my personal Instance, it is working fine with the below script. Please have a look at it.

 

Also make sure, the users should have the user role of your table. 

TahaHabib_0-1672044156036.png

 

Use the following script in your write ACL:

 

answer=false;
if(gs.getUser().isMemberOf("owned_by_group"))
{
   
  answer=true;
}

 

If the above information helps you with your requirement, please mark this solution as helpful and correct. Thank you.

View solution in original post

2 REPLIES 2

RaghavSh
Kilo Patron

try below:

 

answer=false;


var list = current.owned_by_group.toString().split(',');


for (var i = 0; i < list.length; i++) {

if (gs.getUser().isMemberOf(list[i])){
answer=true;

break;

}
}


Raghav
MVP 2023

Taha Habib
Tera Guru

Hello Abdul, I believe the last if condition alone is enough to complete your requirement. I am assuming you have a group called "owned by group", which has some users in it, and you want only those users to write to the record. I have replicated the requirement in my personal Instance, it is working fine with the below script. Please have a look at it.

 

Also make sure, the users should have the user role of your table. 

TahaHabib_0-1672044156036.png

 

Use the following script in your write ACL:

 

answer=false;
if(gs.getUser().isMemberOf("owned_by_group"))
{
   
  answer=true;
}

 

If the above information helps you with your requirement, please mark this solution as helpful and correct. Thank you.