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
HeenaHeena 

Getting ORG ID in Apex Class

Hi,

 

I wanted to know if it is feasible to access the org id of my salesforce org (without  querying the Organization table) in an Apex Class. Something similar to what we do in VisualForce using the {!$organization.id} global field.

 

Thanks,

Heena

Best Answer chosen by Admin (Salesforce Developers) 
AlsoDougAlsoDoug

You could try

 

UserInfo.getOrganizationId

All Answers

AlsoDougAlsoDoug

You could try

 

UserInfo.getOrganizationId

This was selected as the best answer
HeenaHeena
Thanks AlsoDoug.
AlsoDougAlsoDoug
Good to know it worked :robothappy: