How to get an ID of a field in Salesforce


Programming is very easy in salesforce when we know everything but if we don’t know it then there is no need to panic because nobody is perfect in this world, we all learn by experience and knowledge as to enhance our knowledge last time told you about the getter and setter function in the salesforce and in continue to that this post is about how to get and ID of a field in salesforce, there are two ways to get ID of the field in salesforce and both the method is very easy so let’s see how to get an ID of field.

Method 1:Getting ID of the field from field property page

In this we would get ID of the field from the property page of the field which gets opened when we clicked on the field, so see below instruction in detail how we can get the ID of the field

Let’s assume that I want ID of the field ‘Date Closed’ , so open up the object where we have created this field, see below picture for more details as you can see in the below picture ‘Date Closed’ is the field in a object.

field in object

Click on the ‘Date Closed’ Field it would open up property page of this field and in this field you will see many property of this field but you will not see ID of the field on the page instead of that you will see the ID of the page on location address of the browser, see below picture for more details.

ID in the location address BAR

So this is the first method that’s how we can get ID of the field of the custom object but the same thing we can’t do for the standard object.

Method 2:Getting ID of the field from the detail page of the record

This method work for all the field except for the formula fields so in case of the formula fields we have to use our earlier method as i told you earlier now let’s see this method so open up the detail page of any record and double click on that click field and then field allow you to edit itself after that right click on the field and click on ‘Inspect Element’, see below picture for more detail.

right click to inspect element for ID

In the bottom of the browser (Google Chrome or Mozilla Firefox) you would see a small inspect element window where you would see ID of the field, see below picture for more details.

ID in the inspect element window

If you see closely you will notice that both the ID are same so this is the two methods by which we can get ID of the fields, I want to tell you both the methods doesn’t work for the standard objects. I hope you like my post if you have any query you can leave a comment below in the comment section and don’t forget to subscribe my blog and my pages.

Related Articles :

Speak Your Mind



This site uses Akismet to reduce spam. Learn how your comment data is processed.