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
RadnipRadnip 

A tricky one: Is it possible to get the field ID for a field in Salesforce

I'm looking at creating an app but one of the things which would make things a WHOLE lot easier would be the ability to get the Salesforce ID for a particular field (IE not the API name or label but the actual ID). Its not in the meta and I wondered if there was any sneaky way to get it?

RadnipRadnip

Think I found my answer... No :)

michael_mcmahonmichael_mcmahon

I found this post earlier today and I think it might be what you're looking for.  I pasted what might be the relevant part below.  Hope it helps.

 

http://phollaio.tumblr.com/post/22058010643/salesforces-url-structure

  Objects’ specific URLs

Every Salesforce’s object has it’s specific URL, here are listed the links to the standard objects:

Objects URLs Objects’ code

Accountshttps://[instance].salesforce.com/001/o001
Contactshttps://[instance].salesforce.com/003/o003
Leadshttps://[instance].salesforce.com/00Q/o00Q
Caseshttps://[instance].salesforce.com/500/o500
Solutionshttps://[instance].salesforce.com/501/o501
Reportshttps://[instance].salesforce.com/00O/o00O
Opportunitieshttps://[instance].salesforce.com/006/o006
Campaignshttps://[instance].salesforce.com/701/o701
Productshttps://[instance].salesforce.com/01t/o01t
Yoganand GadekarYoganand Gadekar

As of now: No. Its not possible to do it in apex.

RadnipRadnip

@

Yoganand GadekarYoganand Gadekar

If the number of fileds are few then you can use custom labels to store id's and then use them. 

RadnipRadnip

But I'm assuming you would have to manually populate the custom labels with the Id values? I'm trying to find a programatic way of getting the IDs without needing to screen-scrape which I REALLY don't want to do.