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
rfanningrfanning 

Error on Organization object

I am getting the following error for a Salesforce Standard User:

"System.Exception: No such column 'Name' on entity 'Organization'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."

For a Salesforce System Administrator, I do not get this error, which leads me to believe it is a permission issue.  However, when I go to Administration Setup -> Security Controls -> Field Accessibility, the 'Organization' object is not present with the other standard objects (Account, Contact, etc.).

Additionally, this error is occurring in a managed package.  In version 1.8 of my managed package, I did not receive this error with a Salesforce Standard User.  However, the error is occurring in version 1.9 of my managed package although the error-causing code did not change.  Maybe there was an error with the upgrade?

For completeness, here is the Apex code that is causing this error:

List<Organization> orgList = [Select o.Name, o.Id From Organization o];

Thanks in advance!
Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

Just checked the API reference guide (should have started there, I guess), and it indicates the user needs "View All Data" to see this object.

 

All Answers

JimRaeJimRae
Looks like, according to the help, that the user's profile must have "View Setup and Configuration" to get access to that data.
rfanningrfanning

Jim, Thanks for your quick reply.

 

I looked at the permissions on my Salesforce Standard User, and that user has the 'View Setup and Configuration' permission checked under 'Administrative Permissions'.

 

Could it be related to an upgrade to the managed package? (I did not get this error before I upgraded the package with the Salesforce Standard User and the error-causing code did not change in the upgrade.)

JimRaeJimRae

Just checked the API reference guide (should have started there, I guess), and it indicates the user needs "View All Data" to see this object.

 

This was selected as the best answer
rfanningrfanning
During my upgrade, I had also locked down some of my permissions with the "with sharing" keyword and it looks like I locked things down a little too much.  Thanks!
blueandgoldblueandgold
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.