canRead() is returning an erroneous value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 12:47 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 01:08 PM
post your entire script and how it is executed, and maybe someone here can assist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 01:16 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 01:18 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 07:04 AM
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.