We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to restrict records to users based on roles and state

kalp
Tera Contributor

Hi,

I need to restrict draft state records to users, when the logged in user is not the requestor.

how to achieve this using acls. please let me know

 

Thanks in advance,

Kalyani

 

18 REPLIES 18

Hi ,

please find screenshot below

kalyani23_1-1707298864427.png

 

Hello @kalp 

 

Try below code

if(!gs.hasRole('admin'))

{

if(current.request_status=='Draft')

{

current.addQuery('requester_name',gs.getUserID())

}

}

 

If requester_name is correct field name and if  it is reference field then it will work

 

 

 

Hi ,

Tried the same code and still not working .

yes the field_name is correct.

Hello @kalp

 

Try below code

if(!gs.hasRole('admin'))

{

if(current.request_status=='draft')

{

current.addQuery('requester_name',gs.getUserID())

}

}

 

Could you please try above code if it won't work send me the choice value of draft state

kalyani23_0-1707303586348.png

kalyani23_1-1707303637496.png

Hi, please find screenshots