4

I want all the index fields of a particular object in apex. I have searched through the Schema describe but couldn't find a way to identify the field as indexed.

| improve this question | | | | |
  • You can get the external ids ¿Why do you want to know all the index fields? – Torsen Dec 18 '17 at 7:25
4

It's not in the describe, but you can query the FieldDefinition via the Tooling API and it has an IsIndexed field.

List<FieldDefinition> indexedAccountFields = [
    SELECT QualifiedApiName FROM FieldDefinition WHERE IsIndexed = true
    AND EntityDefinition.QualifiedApiName = 'Account'
];
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.