Activity Forums Salesforce® Discussions How to get Custom field id in Salesforce?

  • Sourabh

    Member
    September 15, 2016 at 12:30 pm

    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

  • PRANAV

    Member
    January 19, 2018 at 12:48 pm

    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

    urlhacking11

    Hope this helps you.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos