Wednesday, 2 November 2016

Getting Custom Field Id without hardcoding through Tooling API (Without Http Callout also)

Hi,

We can get custom field ids for URL hacking to auto populate through Tooling API as shown below.

Apex Code:

List<FieldDefinition> fieldList =  [SELECT DurableId,QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName ='Account'and QualifiedApiName='NoofEmployees__c'];
String NoofEmployeesId = fieldList[0].DurableId.split('\\.')[1];

Visualforce Page (Java Script):

<script type="text/javascript">
            var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="../../soap/ajax/38.0/connection.js" type="text/javascript"></script>
<script>
var qr = sforce.connection.query("SELECT DurableId,QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName ='Account'and QualifiedApiName='NoofEmployees__c'" );
              var NoofEmployeesId = qr.getArray("records")[0].DurableId.split('.')[1];
 </script>


17 comments:

  1. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..

    Salesforce training in chennai

    ReplyDelete
  2. excellent guide its much useful for my students career keep share more things about Salesforce for us. thanks for shared your post. keep it up.
    salesforce training in chennai

    ReplyDelete
  3. can you suggest me the latest technical ideas for custom field id with API tools

    Salesforce Training in Chennai

    ReplyDelete
  4. Excellent post!!! In this competitive market, customer relationship management plays a significant role in determining a business success. That too, cloud based CRM product offer more flexibility to business owners to main strong relationship with the consumers.

    salesforce training in Chennai

    ReplyDelete
  5. Thank You for sharing your article. I like it. We provide TIBCO Online Training in Hyderabad.

    ReplyDelete
  6. your information is really awesome as well as it is very excellent and i got more interesting information from your blog.
    PHP Training in Chennai

    ReplyDelete
  7. I really appreciate for your efforts to make things easy to understand. I was really many students struggling to understand certain concepts but you made it clear and help me bring back my confidence.

    Sales force online training in hyderabad
    Sales force online training in usa
    Cloud computing training in hyderabad

    ReplyDelete
  8. This blog explains the details of most popular technological details. This helps to learn about what are all the different method is there. And the working methods all of that are explained here. Informative blog.
    SAT Training Centre in Chennai

    ReplyDelete
  9. Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post buddy..
    Fresher Jobs
    Fresher Opening

    ReplyDelete
  10. Thanks for sharing a good information about salesforce . .......This article is very useful to learners. Sales force online training

    ReplyDelete

  11. Its very useful to me. Wonderful blog.. Thanks for sharing informative Post.

    Installment loans
    Payday loans
    Title loans

    ReplyDelete
  12. Its fantatic explaintion lot of information gather it...nice article....
    seo company in Chennai

    ReplyDelete
  13. The article provided by you is very nice and it is very helpful to know the more information.keep update with your blogs .I found a article related to you..once you can check it out
    SalesForce online training

    ReplyDelete
  14. Nice to see blogs like this...got a more useful informations..spent a nice time with this blog.keep more updates like this..
    Instant tax service
    Small Business accounting
    Business tax preparation
    Business Tax Return

    ReplyDelete