How To: Display Salesforce Encrypted Fields
Show encrypted Salesforce field values in S-Docs and avoid common query sorting errors.
Use this guide when a Salesforce field is encrypted but still needs to appear in an S-Docs document.
Before you start
There are two different encryption models for merge fields:
Classic Encryption uses a custom field type - Text (Encrypted) - and character masking.
Platform Encryption is applied through the Salesforce Setup 'Platform Encryption' section.
Solution 1: Classic Encryption
By default, if a User has permission to View Encrypted Data and can see an Encrypted field on the record page, the field will be decrypted/unmasked when the document is generated.
To apply the mask to the field for outgoing documents, use encrypt="true" on the merge field.
{{!Opportunity.Encrypted_SSN__c encrypt="true"}}If the field is masked for the generating User on the page, the field will always be masked in the generated document.
Use this only with Salesforce Classic Encryption.
Solution 2: Platform Encryption
With Platform Encryption, use the field like any other merge field.
The most common fix is enabling the Platform Encryption setting under Custom Settings.
After that, review any query that sorts by the encrypted field.
Common error
If users see this error:
field 'FieldName' can not be sorted in a query call
the query is trying to sort by an encrypted field.
This is commonly resolved by enabling the Platform Encryption setting under Custom Settings.
Keep going
Review Template Attribute Reference for exact
encryptsyntax and limits.If the issue starts after a sandbox refresh, review S-Docs Installation Error Encryption Key Unavailable.
Last updated
Was this helpful?

