+ Start a Discussion
lnryanlnryan 

Global Variable in Apex

How do you get access in APEX to the same global variables that are available in formulas and VisualForce. I'm looking for a non-SOQL based way to access this org-wide and environment-based settings. Particularly, is there a corresponding settings variable to $RecordType?

CoryCowgillCoryCowgill

Not to my knowledge.

 

For RecordType information in APEX you will need to query the RecordType table using SOQL.

 

There are some Apex classes which have static methods to access system information like UserInfo and such. Checkout the reference section of Apex Developer Guide: http://www.salesforce.com/us/developer/docs/apexcode/index.htm

 

If your hiting governor limits with your SOQL, a potential workaround is putting some information in the Custom Settings and retrieving the information from there. Custom Settings do not count against your SOQL limits. Of course the drawback here is your duplicating data, maintenance, etc. But it would get you around making a SOQL call.

 

http://developer.force.com/releases/release_feature?key=Custom+Settings

lnryanlnryan

Yeah, sadly i'm familiar with all those. It's helpful feedback to know others come up with those same options, though...

 

I did find a solution for RecordType information that avoids a SOQL call: Schema.recordtypeinfos. It's available on a per-object bases and has governor limits distinct from those for describe calls.

 

If I could get confirmation from someone that there is indeed no functionality in apex for this, i'd request it on the idea board....