A5 Documents allows you to dynamically merge images into your Document Action template using a text or formula field that provides a URL to a publicly available image (supported image types include jpg, jpeg, png, gif). The URL of the image can be copied from publicly available sources, including a Document attached to a record (Classic only), Google Drive public folder, Google Drive main folder, or a web source.

  1. Create a Custom Field
  2. Choose the URL Source
  3. Paste URL into the Custom Field
  4. Merge the Field into the Template

Create a Custom Field

  • Choose your base object, then create a custom field to hold the URL. Field type should be “long text” rather than URL, since the URL Sources in this article will have URLs that exceed the 255 character limit.
  • For example, if you’d like to merge a logo into a document and your base object is Opportunity, create a custom field (“Long Text” type) called Logo Link on the Opportunity object that displays the value of the Logo Link field.
  • Add this field to the object’s page layout.

Choose your URL Source

Choose from three supported sources for your publicly available URL:

Document attached to a record (Classic only)

In order to merge images into a document from a Documents file in Salesforce, you ‘ll need a publicly available URL to the direct image.

  • Go to Documents tab in Salesforce.
  • Select the checkbox “Externally Available Image” to make the document available externally.
  • Right click the image and select “Copy Image Address”.

File attached to a record (Lightning)

Files can now be shared publicly, so if you can save the public URL for the file into a custom “long text” type field, then you can use that field to merge onto a template. If you go to the file and click on File Sharing Settings, share with link, copy that link. Open it. Then, in order to get the URL of the image itself, right click on the image displayed and select “Copy Image Address” and proceed to the next step.

Google Drive – Public Folder

If you would like to merge images that are stored on Google Drive, this is possible; however, the link provided by Google does not work as provided so some modification is necessary.

  • Put your files in a public folder:
    • Create a folder or choose an existing folder.
    • Right click “Share” button at top right of screen.
    • Change settings to “Anyone with Link”=”Viewer”.

  • Any file in the folder will be made publicly available by entering URL in this format: https://googledrive.com/host/<folderID>/<filename>.
  • For example, if you created a test folder on Google Drive and uploaded a file Test-Image.png, the Image URL is: https://googledrive.com/host/0BwdB0jiqM9yCXzlGeDZjaUhYZFk/test-image.png.
  • Copy the new image URL and proceed to next step.

Google Drive – Main Folder

If you don’t want to put files into a shared folder, you can use images that are uploaded directly to Google Drive (as long as they’re publicly accessible).

  • The image URL format will be: https://docs.google.com/uc?id=<file-ID>.
  • For example: If you uploaded a file directly to your drive with a file ID of 0BwdB0jiqM9yCM01iekxpdlc4ZHc, the Image URL is:  https://docs.google.com/uc?id=0BwdB0jiqM9yCM01iekxpdlc4ZHc.
  • Copy the new image URL and proceed to the next step.

Web Source

You can merge images from a publicly available web source, such as your server, WordPress Media library etc.

  • To copy the direct URL of the image, right click the image and select “Copy Image Address” and proceed to the next step.

Paste URL into the Custom Field

  • Open the record and paste the copied image URL value into your custom “long text” type field.
  • For the example, we have an Opportunity record, Sustainable Energy Partnership, and would like to add a logo from a publicly available Documents file.
  • Paste the link into the Logo Link field on the Opportunity record.

Merge the Field into the Template

  • From your Document Action click “Edit Template Document” to edit the template.

  • Select the base object and image field. In this example, select “Opportunity” and select the image field, Opportunity>Logo Link
  • Check the “Image” checkbox.
  • The merge field code will populate in the “Merge Field Code” field at the bottom for you to copy and paste into the template body, header, or footer. 

Example Document Action Template:

Example Generated Quote Document: