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
Admin User 476Admin User 476 

Unable to query the 'IsSandbox' field of 'Organization' object

Hi,

As per the summer'14 release notes, salesforce has added the read-only fields InstanceName and IsSandbox to the Organization object. I'm trying to add the following query to my apex classes:

Organization currOrg = [Select IsSandbox from Organization limit 1];

But when I try to save the code, I'm getting the following error:

No such column 'IsSandbox' on entity 'Organization'.

It works fine if I run the above query using developer console, returning 1 row with OrgId and true (testing in sandbox). I don't understand why I can't save my apex classes with this query. Any help is appreciated. 

Thanks!


Best Answer chosen by Admin User 476
SamuelDeRyckeSamuelDeRycke
Are you, by any chance, trying to save this in a class of an old API  version ? I can save your code without any problem in an apex class of api version 31.

All Answers

SamuelDeRyckeSamuelDeRycke
Are you, by any chance, trying to save this in a class of an old API  version ? I can save your code without any problem in an apex class of api version 31.
This was selected as the best answer
Admin User 476Admin User 476
Yes, you are right. My class was of API version 30! It saved my class without any errors when I updated the version to 31. Thanks for catching that!
SamuelDeRyckeSamuelDeRycke
You're welcome :-)