I am using salesforce soap api partner WSDL. For example i have a custom field of lead abc__c which is a lookup field and pointing at suppose Account. Now in my code i get this custom field name and its type is reference now all i want is to get the table name at which it is pointing at in Salesforce. I am new to salesforce so sorry if i said any thing wrong not have too much domain knowledge. So please help me.

  • Welcome to SE. Visit the help section to learn how to post a good question. thumb rule is always add your code while asking a question, it will help other to identify the issue and it will also reduce extra conversation on question.
    – Himanshu
    Feb 11, 2016 at 19:20
  • Suppose i have only custom field name abc__c as a string in my code and it is also present in my saleforce account as a lookup custom field i only want to know which table its pointing at is it account or campaign etc Feb 11, 2016 at 19:28
  • if abc__c is string field it can't point to any other object. post a screenshot
    – Himanshu
    Feb 11, 2016 at 19:36
  • No your understand it totally wrong in my code of java i have the field name abc__c in any string variable which i know it is a lookup field in salesforce but as you know every lookup field is pointing at another table in salesfoce. So only using the name of custom lookup field in my string variable what should i query or something like that so i get the name of table at which my custom field is pointing in Salesforce. Feb 11, 2016 at 19:49
  • Field names don't have to be unique across objects, so there is no good general way to do this.
    – martin
    Feb 18, 2016 at 3:14

2 Answers 2


You can get this information using Salesforce metadata api. You can follow below steps

  1. Calls describeGlobal() to retrieve a list of all available objects for the organization’s data. The describeGlobal method determines the objects that are available to the logged in user.

  2. Calls describeSObjects() to retrieve metadata (field list and object properties) for a specified object. The describeSObject method illustrates the type of metadata information that can be obtained for each object available to the user. Object metadata information includes permissions, field types and lengths, and available values for picklist fields and types for referenceTo fields.

  3. Iterate over results returned in step 2 and compare with your string variable abc__c.

  4. Calls query(), passing a simple query string ("SELECT FirstName, LastName FROM objectname").

Following tutorial contains different methods which you can take as starting point. https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_quickstart_steps_walk_through_code.htm


With the SOAP API you can retrieve the DescribeSObjectResult for the sObject type of interest using describeSObject(string sObjectType) call. This includes the fields collection in the result.

Find the Field with the matching name for "abc__c" field. There will be a referenceTo string[] property that:

indicates the object types of the referenced objects.

Since your field won't be polymorphic the first string in this array will be the API name of the references sObject Type.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .