For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

If your org uses Platform Encryption, use a normal merge field.

Also enable the Platform Encryption setting under Custom Settings.

Solution 1: Classic Encryption

Use encrypt="true" on the merge field.

{{!Opportunity.Encrypted_SSN__c encrypt="true"}}

This decrypts the value at render time for users who already have permission to View Encrypted Data.

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.

1

Confirm field access

Make sure the generating user can view encrypted data in Salesforce.

If the user cannot view encrypted data there, S-Docs cannot display it in the document.

2

Add the field to the template

Use a normal merge field for Platform Encryption.

Use encrypt="true" only for Classic Encryption.

3

Enable the Platform Encryption setting

Open the S-Docs Custom Settings in Salesforce.

Enable the Platform Encryption setting.

Save the change.

4

Check direct SOQL related lists and named queries.

Look for an ORDER BY clause that uses the encrypted field.

5

Sort by a different field if needed

Replace the encrypted sort field with an unencrypted field like CreatedDate, Name, or LastModifiedDate.

6

Save and test

Generate from a real record.

Verify the encrypted value appears and the query no longer fails.

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

Last updated

Was this helpful?