ACL to look at users country

M_iA
Kilo Sage

Hi, without using glideRecord on an ACL script, what would be the best way to script my ACL so that it checks the current users country code to determine whether they can view the record.

Appreciate that a BR is probably best, but there are currently a lot of ACLs in play, so just want to update the existing ACLs.

So for example, if the current users country code is "united Kingdom" or "England", they can view the record. But if the current users country code is anything different, they cant.

Many thanks in advance

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

without GlideRecord it's not possible as there is no direct way to obtain country code.

you can get location or company directly using this but not country code

gs.getUser().getCompanyID();
gs.getUser().getLocation()

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

without GlideRecord it's not possible as there is no direct way to obtain country code.

you can get location or company directly using this but not country code

gs.getUser().getCompanyID();
gs.getUser().getLocation()

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

umaaggarwal
Giga Guru
Giga Guru

You can use this. It is working for me 

 

gs.getUser().getRecord().getValue("country");

 

Thanks!

Uma

umaaggarwal
Giga Guru
Giga Guru

Below is what I used and what I received as an output in background script. You can use the same

 

gs.print(gs.getUser().getRecord().getValue("country"));

Output:     *** Script: IT

 

Please mark this correct and helpful if it really helps

 

Regards!

Uma