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
chris.noechris.noe 

Get Masked Value of Text (Encrypted) In Apex

I have a use case where I would like to access the masked value of an encrypted field via Apex.  I am actually writing the value of the masked field to a regular text field on a separate object.  The text field on the other object cannot be defined as encrypted because it will accept encrypted text fields with different formats.  As a result, I just want to update this field with the masked value of the encrypted field.  When I attempt this via Apex, it always writes the unmasked value.  Anyone found a way to access the masked value of an encrypted field via Apex?

 

Thank you,

ForcepowerForcepower

Chris,

 

Encrypted fields are encrypted in storage and are available to Apex in an unencrypted fashion. The masking is mainly enforced on the UI. I'm not sure if there is a way to obtain the masked value from the field through some kind of an API / object method. You could look at masking it yourself when writing to the other field. It's not ideal but may be an option in the absence of a better one.

 

Ram