User Criteria script not working when i checking the user based on business type

rahul16
Giga Guru

var grUser = new GlideRecord('sys_user');
grUser.addQuery('sys_id', user_id);
grUser.query();
if (grUser.next() && !grUser.department.nil() && !grUser.department.business_unit.nil()) {
answer = grUser.department.business_unit.name.toString().toLowerCase() == 'test';
} else {
answer = false;
}

What is wrong with the script I want to show my scoped form to only users with business unit name as a test only but it is not working.

rahul16_0-1665737977830.png

 

1 ACCEPTED SOLUTION

rahul16
Giga Guru

After using the cache.do it's working fine

View solution in original post

1 REPLY 1

rahul16
Giga Guru

After using the cache.do it's working fine