canRead() is returning an erroneous value

snoozer
Mega Guru

I'm trying to check read permissions of a user on a field in the Incident table. The code I'm using is:

gs.getSession().impersonate(userSysID);
var value = recordGR.getElement('business_service').canRead();   // recordGR is a GlideRecord on the Incident table

 I am expecting 'value' to be false, as this user does not have the ability to read the business_service field. However, the code is returning true.

 

However, I added the field to the Incident form, and when I impersonate the user and go to the form, I can not see the field! Why do I get a conflicting value when I execute the code?

7 REPLIES 7

Bert_c1
Kilo Patron

post your entire script and how it is executed, and maybe someone here can assist.

gs.getSession().impersonate('0016f4f8d474de90206f3637ed37d5aa');
var recordGR = new GlideRecord('incident');
recordGR.get('bee42676b9df4a14c29839f22ecb7e94');
var value = recordGR.getElement('business_service').canRead();
gs.info(value);

Executed in Scripts - Background.

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @snoozer 

Is this ACL or user criteria script ?

 

Can you try using getValue instead of getElement and see if it is working?

Please Mark this answer as helpful and correct if helped.

Kind Regards,

Ravi

 

snoozer
Mega Guru

It is not an ACL. It is a part of an automated test script that tests ACLs.

 

getValue() does not work. The value of the field is empty and so getValue() returns a null value. I can't do a .getRead() on a null value.