I have a formula field called ContactID18__c on the Account object. The formula is CASESAFEID(PersonContact.Id). Can this field be indexed or no because it is a custom field and a formula? Or is there a way to get the ContactID(18) from the Account without doing a formula and that field is indexed.

  • Why do you need an index on the formula when the lookup field itself (PersonContact.id) is indexed? Jun 11, 2018 at 18:11
  • So a 3rd party company built a field called ContactID(18) and we are trying to use that ContactID to call back that ID. The engineer is getting this error message Field name provided, ContactID18__c is not an External ID or indexed field for Account Jun 11, 2018 at 18:41
  • You seem to be having an x-y problem. The issue here is not that the field cannot be indexed, is that somebody is using it incorrectly. Can you post the offending code, or elaborate on the use case? Jun 11, 2018 at 21:00

2 Answers 2


Yes, you can request to have indexes created on custom formula fields provided that they are deterministic - generally speaking, that they don't have cross-object references, dependency on the current date, or references to fields that have some special built-in functionality.


However, I'm not sure why you'd need a custom index on a field whose only purpose is to hold an 18-character Salesforce Id. Note that all Salesforce APIs (including Apex and SOQL) treat 18 and 15 character Ids as equivalent for the purpose of filtering on an Id field. Id fields themselves are indexed.

You can always obtain 18-character Ids by extracting data using the Data Loader or Workbench. They export 18 character Ids by default, unlike Reporting.

Edit: based upon your comments, your process involved inserting Invoices and/or Quotes, and you wish to use your custom formula field as if it were an External Id of the parent Account or Contact. You don't need to do that. The field is providing you with the record Id of the Contact associated with the Person Account, whose Id presumably you already are holding. You can simply populate those Id values directly into Contact and Account lookup fields on the new objects you're creating. You should not need to perform an upsert, use an External Id, or create any new indexes.

  • We are just trying to get that ContactID(18) and pass it to our Ops service. Jun 11, 2018 at 18:46
  • Why do you need an index to do that?
    – David Reed
    Jun 11, 2018 at 18:47
  • I was getting this error message Field name provided, ContactID18__c is not an External ID or indexed field for Account. The engineer said we need to index that field. Jun 11, 2018 at 18:53
  • Are you trying to perform an upsert operation against the field? This kind of seems like an x-y problem. More details will help.
    – David Reed
    Jun 11, 2018 at 18:54
  • Yes, its an update or upsert on the ContactID(18). When a Quote or Invoice is created we want to pull that ContactID(18) from the Account that is creating the Quote or Invoice and push that ContactId(18) to the Invoice or Quote Jun 11, 2018 at 19:00

A formula field cannot be indexed at this time although I understand it's something that is potentially in the works for a future time. Formula fields are only evaluated when the record is actually opened and cannot be indexed for that reason. You can populate a lookup field from another object or using workflow you can populate a text field.

  • 1
    Unless something's recently changed, (some) formula fields can be indexed by request to Salesforce Support.
    – David Reed
    Jun 11, 2018 at 18:12
  • That's not standard OOTB functionality. It requires you to file a case with SF to make it happen. Salesforce also has to "render" the values of those fields in order to create special tables for them when it does that too.
    – crmprogdev
    Jun 11, 2018 at 19:55
  • Formulas can be indexed, but not all type of formulas cant be indexed. Only deterministic kind of formulas are index. Yes.. Indexing in the first place not out of the box functionality Jun 11, 2018 at 19:55

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.