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
ShiztasticShiztastic 

Parsing record IDs

What is the best way (if there is one) to send a record ID to a visualforce page and have the page determine the record type?
 
The ID could represent a contact record, account record, etc.  Do you need to add some javascript to get the DescribeGlobal method and loop thru some metadata and process the ID that way?
 
Thanks for any info...
 
 
Shiztastic
Ron HessRon Hess
Is the id of the record for a specific object (concrete) or for any object in the system ( dynamic) ?

if it is concrete, you can just load that record in your controller and look at the recordtype value.

if dynamic, you may have to loop thru the dynamic (describe) calls to get tokens and check until you have a matching record, then query that record.  I've not tried this yet.


ShiztasticShiztastic
Ron,
 
Thanks for the response.  The ID is dynamic.  I figured I could grab the first 3 characters of the ID to get the type and then loop thru the metadata to find out what kind of record it is.  Can you reference the Describe calls thru visaulforce or do you have to switch over to javascript and use API calls?
 
 
Shiztasic
mtbclimbermtbclimber
In the Summer '08 release you can access Describe information from apex and thus any visualforce page with a custom controller or extension.
Jon Mountjoy_Jon Mountjoy_
Sorry for newb question here:
Given an incoming Id (which I can retrieve), which may be for any object (and I don't know which, Account, Contact, whatever), how do I retrieve an object so that I can go and fetch the describe information?

ie. I don't know how to start this process given an Id.

Thanks,
Jon
jwetzlerjwetzler
It seems like this is more of a question for the Apex Code forums than for the Visualforce forums, since you know how to get the ID from the page.

The documentation for describe (page 100 or so) is pretty helpful:
http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf
ShiztasticShiztastic

Jon,

I am doing the same kind of thing.  With the Summer 08 release, you can use Apex and the Schema.GlobalDescribe method and DescribeSObjectResult to check out info about the ID.   You can use the first 3 characters for the ID to figure out the record type (ie 001 = Account).  The metadata can help match record types.

 

Shiztastic