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

Permissions on Organization object

I have a apex method within a class that has "with sharing". It is run by a user that has a profile very much like to a Read Only profile - i.e. doesn't have View All Data permission. The following code is attempted:


Schema.SObjectType obj = gd.get('Organization'); Map<String, Schema.SObjectField> M = obj.getDescribe().fields.getMap() ;

But fails on the second line with a "Attempt to de-reference a null object" - variable obj is null, the SObjectType for Organization was not retrieved. I change the class to "without sharing" and obj is no longer null but M is blank. No fields were retrieved. If I give the user View All Data permission, everything is fine.

Is this a bug? I was lead to believe that "without sharing" ensures that the sharing rules are not enforced. And I read that View All Data also circumvents records based sharing. But there's something not quite equal here. How are the permissions gained to be able to perform the field describe on the Organization object within an apex class without giving the user View All Data permission?


This is a little worrying, any help much appreciated. Thanks.


We are also facing same type of issue.
Does anyone know if "View All Data" is still required for reading the Organization object in Summer '15? I just did a query via SoqlXplorer on the Organization object with a user whose profile does not have "View All Data" checked, and I was able to see the values of the fields InstanceName and IsSandbox.