ACLs / Security rules should not have GlideRecord/GlideAggregate in script

Rohit Agarwal
Mega Expert

Hi,
I want to avoid database lookups in Access Control rules. Please check the below script. Can we update the code differently (without GlideRecord queries)?

see below script:

var check=false;
var gr=new GlideRecord("sys_user_group");
gr.addEncodedQuery("name=test1^ORparent=123xxxxx789^ORname=test2");
gr.query();
while(gr.next())
{
if(gs.getUser().isMemberOf(gr.sys_id))
{
check=true;
break;
}

}
answer=check;

7 REPLIES 7

Omkar Mone
Mega Sage

Hi 

The script is going to check if the logged in user is member of the queried groups, instead you can put the name there somthing like this - 

gs.getUser().isMemberOf("test1"); or condition in if like this.

 

Hope this helps.

Regards

Omkar Mone

Hi Omkar,

How can I search group name using group Parent without using GlideRecord??

For example, 

Parent group - P1

Associated child group - C1,C2,C3

is this possible??

 

Hi 

You can get all the groups that current logged in user with this-

var groups = gs.getUser().getMyGroups();

 

The if you want you can check with the sys_id of the parent if user belongs to that group.

Hi Omkar,

my require here is that i have the sysID of parent group. Now I want the all child group under that parent group without using gliderecord. is this possible??