+ Start a Discussion
kartik.skartik.s 

Getting record details (say object type) with only ID

Hi,

           I am working on a solution, where i have the ID of a record and would like to get the details of this record, say the object type of the record. This ID is from the ParentID of an attachment object. So basically i want to get the object type of record that contains this attachment. Any suggestions ? Thank you.

SuperfellSuperfell
You can use the keyPrefix values from describeSObject to map back to the object type, but often its easier just to fetch the object type at the same time you fetch the Id, e.g. something like select id, name, parentId, parent.Type from attachment (parent.Type will be the sobject type of the parentId id).
kartik.skartik.s
I did try the ParentType field from attachment object to get the Object Type, but it doesn't seem to be present in the attachment field list. Anyways i got it working using the keyPrefix values as you suggested. I really only needed the object Type, thats fixed now. Thanks for your help.
SuperfellSuperfell
the field is on the parent relationship, not on the attachment object directly, the SOQL i posted works fine. (try it in SoqlX)
kartik.skartik.s
Never tried out SoqlX before, I will ook into it. Thanks for the suggestion. 
Carl_V1Carl_V1
Hi All,

I dont quite understand the answer provided thus far but would love to understand how to identify definitively which object a specific record comes from, provided I have an Id.  For example, have 'Demo_Object__c' returned to me so I can then perform a modification on the record itself.

Any suggestions appreciated!