1

I have a formula field based on a date field, and I want to have the date field encrypted using Shield Platform Encryption. But when I try to turn the encryption on I get:

Error on fields update message=Encryption can't be enabled for fields referenced in the custom formula fields: Benefit Claimed.Years in Force at Date of Death. Make sure your permissions, fields, operators, and functions are compatible with encryption and try again. statusCode=FIELD_INTEGRITY_EXCEPTION fields=null

Part of the formula is:

YEAR(DateOfDeath__c) - YEAR(EffectiveDateOfCoverage__c)

Am I correct that I am stuck here, and that e.g. YEAR is never amongst the:

... functions are compatible with encryption ...

mentioned in the error message?

I am trying to see if having all the fields referenced in a formula encrypted is a workaround for Platform encryption scratch org errors "common.exception.SfdcSqlException: ORA-00932: inconsistent datatypes: expected CHAR got DATE". But also having this field encrypted makes sense.

  • You could move the computation into Apex. – Adrian Larson May 7 at 18:01
  • We ran into the same issue, we wanted to display age in UI based on date of birth which we had to encrypt due to PII restrictions, finally we got rid of the formula field and did the calculation in run time UI. – RedDevil May 7 at 18:05
  • Thanks@AdrianLarson and @RedDevil; this managed package is live for many customers so such a change has its risks. But sounds like there is no easy solution. – Keith C May 7 at 18:07
  • we had same issue in our org and I resorted to managing the value in apex – cropredy May 8 at 1:34
  • Thanks @cropredy; that is 3 out of 3 for having to use Apex. – Keith C May 8 at 6:42
3

You can read the value of an encrypted field in Apex. That would allow you to replace this formula field with a writeable field and move the calculation to an Apex Trigger (or some other Apex binding).

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.