Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Script condition for ACL not working

Jason_DaSilva
Tera Guru

We have a section of our IT staff that have access to some areas of SN but not others.  This spans various groups, but we have created a custom flag of u_ecr.

on a table, I am trying to restrict read rights to memebers who have u_ecr as false.  If u_ecr is true, you should be denied access to view this table.


I thought this would be a simple script of : 

if(gs.getUser().getRecord().getValue('u_ecr') == 0){
  answer = true;
}

But when this script is in place, no one can view the table.  I had even tried adding an else for the answer = false.  Still same outcome.  in xplore, I have run this code to test the outcome of gs.getUser().getRecord().getValue('u_ecr'), and it returns the proper 1 or 0 depending on the user.  Am I writing the ACL condition script incorrecty?  If I set it to just plain aswer = true; it works fine.

 

1 ACCEPTED SOLUTION

Voona Rohila
Tera Patron

Hi @Jason_DaSilva 

Try this

 

var grSysUser = new GlideRecord('sys_user');
if (grSysUser.get(gs.getUserID() )) {
if(grSysUser.u_ecr == 'false') //modify value according to req
	answer = true;
}

 

 

Refer below KB Article

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723759

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
5x ServiceNow MVP

View solution in original post

2 REPLIES 2

Voona Rohila
Tera Patron

Hi @Jason_DaSilva 

Try this

 

var grSysUser = new GlideRecord('sys_user');
if (grSysUser.get(gs.getUserID() )) {
if(grSysUser.u_ecr == 'false') //modify value according to req
	answer = true;
}

 

 

Refer below KB Article

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723759

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
5x ServiceNow MVP

only a slight modification needed for this to work.  Seems it prefers 1/0 over true/false.  This worked as a final cut of the code:

var grSysUser = new GlideRecord('sys_user');
if (grSysUser.get(gs.getUserID() )) {
if(grSysUser.u_ecr == 0) //modify value according to req
	answer = true;
}

 

Thanks!