February 1, 2012

New Idea, Getting Field ID in Apex Describe Information !

If you are planning to default input field values in an edit page for an Sobject, then you need to use something cryptic, like LKID hack. This hack requires you to pass field’s IDs as URL query params with default values for each, like:


This solution is really a hack, as there is no way in Apex describe information to know ID for a given sobject field. This makes your app or solution tough to port across the orgs, developers try to use custom settings to declare all such LKID fields, each one of them must be correctly updated by Admin post app installation.

One hack, and the easiest solution so far !

Keith Clarke has done a great job to solve this problem in best possible way as of now on platform. Here are few posts and thoughts from Keith about the same:


IdeaExchange - Field ID needed in Apex Describe Info !

I appreciate efforts and the solution from Keith Clarke, but the approaches we still have are hacky and prone to failures. It would make our life much simpler, if Apex describe information includes information about the field ID also. For ex.

Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.Name;
// This new method is very much required
Id fieldId = f.getId();

I am posting the same as an Idea, please promote it to make developer’s life easier in future. Here is the link to the idea : https://sites.secure.force.com/success/ideaView?id=08730000000gM7mAAE