function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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?
 
AshlekhAshlekh
Hi,

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.

-Thanks
Ashlekh Gera
 
Mohit MoolaniMohit Moolani
Hi,
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

Thanks,
Mohit Moolani