function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Christoph EschweilerChristoph Eschweiler 

SObjectField method "getDescribe()" returns exception starting Summer 19

Hello,

starting Summer 19 we recognized a change in APEX behaviour:

for a custom sObjectField, the getDescribe().getName() Method returns an exception for a user who does not have permission to view a related object.

We have a custom object Payment__c that is linked via lookup to a custom object "Invoice__c". The lookup field on Payment__c cannot be described by a user anymore that does not have the permission to access the Invoice__c object.

So, if I execute this as a user without access to the target object:

Payment__c.Invoice__c.getDescribe().getName()

I get an exception. We're on API 44 with all our code.

Can anybody confirm this? This seems to be a bug since no change in behaviour is documented anywhere (and should not be applied to older versions).

FYI: The same code still works as expected in orgs that are not yet on Summer 19.

Christoph EschweilerChristoph Eschweiler
The exception that is being thrown is: System.SObjectException: Field Payment__c.Invoice__c is inaccessible in this context