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

method like describeSObject with API

Hi, I'm trying to gather all fields of Object. For instance, Name, Id, Tel, WebSite,....of Account.
I know we could do it with API - describeSObject( Account ), but do you know how to do it with Apex Code?

Please let me know if anyone knows it...

Thank you very much,
I do not believe this is currently possible with Apex as it does not yet have the ability to look at the metadata of an object.

Rumor has it the next version of apex will be able to do this, select *  from, but there is no word on ETA.

Message Edited by TehNrd on 03-20-2008 01:30 PM
Yes, I've heard of the rumor...Hope it'll come out soon..

BTW how do all guy get meta-data dynamically with Apex Code..?

Do you know some workaround about it..?
For anyone who runs across this in the future- this functionality is described in the APEX docs here.

Message Edited by cgoss on 07-24-2008 09:27 AM


Here's the exact code in case someone wants it ('cause it took me awhile to figure out) :



//SObject mySObjectInstance = something

Map<String, Schema.SObjectField> myFieldNames = mySObjectInstance.getSObjectType().getDescribe().fields.getMap()