Tutorial: How to Add Dynamic Signatures

Use case: You want to add a signature image to your document. The signature is, for example, a scanned image is stored in one of your organization's Salesforce libraries.

This tutorial will show you how to add a dynamic signature image for the user who is the Opportunity owner. The same method can be applied in other cases to get the user's signature.

Step 1: Check custom field ‘Signature Owner’ in ContentVersion object

  • In Lightning, under Setup > Object Manager, choose object Content Version
  • In Fields & Relationships, check to see if the custom field ‘Signature_Owner__c’ (label: Signature Owner) already exists. If not, create the Signature Owner custom field, with the definition details as below:

Step 2: Assign signature ownership to users

In the Salesforce library that stores your users' signature images, assign the ownership of each signature image to the relevant user.

Step 3: Query and load the signature image

In order for dynamic signature images to appear, we have to add a query to get the signature image and load it to the document.

  • On the image placeholder, click on ‘Logic’ inside the ‘Tag’ tab.
  • In the ‘Logic’ view, add the following tags/commands from the left pane into the workspace, you can enter the value(s) for each tag/command in the right pane. The input for each command is shown below:

- query:

  • Var: the variable to hold the image query result. Here we call it signatureQuery
  • Select - Please enter this query:

 SELECT Id, IsLatest FROM ContentVersion WHERE IsLatest = true AND Signature_Owner__c = '${Opportunity.Owner.Id}' 

- if (if the query result is not empty, load the signature image into the document):

  • test: ${not empty signatureQuery}

- load (as a child command of ‘if’):

  • var: the variable to represent the actual signature image. Here we call it signatureImage
  • recordId: ${signatureQuery.Id}

Step 4: Add the signature image variable

In the right pane of the document editor, add the signature image variable (in this case we called it signatureImage) as the Dynamic Source attribute for the image.


In some cases, a ‘load’ error might appear (and the signature image doesn't show up). This might be from the fact that the template hasn’t loaded the field ‘Owner.Id’ for the Opportunity object. If you encounter such an error, follow the instruction below to add this field to the logic of the template:

  • Go to Advanced UI > Main Flow > Before > Initialize (Initialize is a step in the template flow that defines variables and sets main data sources for the template to work)
  • In the ‘record’ tag/command, add Owner.Id (case sensitive) to the ‘fields’ section.