Activity › Forums › Salesforce® Discussions › How to get Custom field id in Salesforce?
-
How to get Custom field id in Salesforce?
Posted by Tanu on September 15, 2016 at 12:17 PMHi All,
How to get Custom field id in Salesforce?
PRANAV replied 8 years, 3 months ago 3 Members · 2 Replies -
2 Replies
-
Hi Tanu,
To get custom field Id in Salesforce you have to use Tooling Api. Here is a piece of code , Hopefully it will help you.
HttpRequest req = new HttpRequest();
req.setHeader(‘Authorization’, ‘Bearer ‘ + UserInfo.getSessionID());
req.setHeader(‘Content-Type’, ‘application/json’);String toolingendpoint = ‘https://na1.salesforce.com/services/data/v20.0/tooling/’;
//query for custom fields
endpoint += ‘query/?q=select+id,DeveloperName,FullName+from+CustomField+limit+1’
req.setEndpoint(endpoint);
req.setMethod(‘GET’)Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());Thanks
- [adinserter block='9']
-
Hi Tanu,
You can get custom field id by following the below steps:
- Login to salesforce.com
- In the top right corner, click on Setup
- Click on Customize, select Opportunities and then click on Fields
- Click on the name of the custom field you want.
- Look at your browser’s address bar, you’ll see something like: //ap1.salesforce.com/00N0K00000K04Ol?setupid=OpportunityFields
- The 15 digit code that appears immediately after //ap1.salesforce.com/ is the ID of that custom field; in this case the ID of the custom field selected is 00N0K00000K04Ol
Hope this helps you.
Log In to reply.
