+ Start a Discussion
Marat KalibekovMarat Kalibekov 

How to know if field is indexed or not via API?

What API must be used? I want to know if field is indexed or not for all types of the fields, system and custom. Partner API or Metadata API should be used?

As there are no any method in field describe which tells you that is a index field. But there are some documentation which say that this type of fields are index so on bases of that you can relay that these fields may be index fiedls.

The standard Salesforce indexed fields are:

 Lead: Company, Email, Lead Owner, Name.

Contact: Account Name, Contact Owner, Email, Name, Reports To.

 Account: Account Name, Account Owner, Account Record Type, Parent Account,

 On top of these, system time fields (last modified, created date etc) and any lookup fields are also indexed.

Unique and External fields are also consider as a index fields.

Ashlekh Gera
Mohit MoolaniMohit Moolani
There is a way using tooling api by which we can find out which all fields are indexed in a particular object.
Example - 
SELECT QualifiedApiName
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName ='Account' and IsIndexed = true
This example is listing all the fields which are indexed in Account object

Mohit Moolani