Skip to main content
Conga Support

Merge Images with Salesforce ID in Word

You can include an image into a template document by using a Salesforce® ID instead of a complete URL address.

If the image exists in Salesforce as a Document (record ID beginning in “015”) or Attachment (record ID beginning in “00P”), you can reference the ID of the Document or Attachment and Conga Composer® calculates the rest of the image URL.  You will still use the field prefix IMAGE: but do not have to build a custom field to house the image’s URL. Instead, you retrieve the image’s ID from a SOQL query.

  Getting attachment images to embed in a document only works with Word and is not an option with Conga Email, PDF or Excel templates.

You have uploaded an image as an Attachment (on the Notes & Attachments related list) on an Account and want to merge that image into your Word® template.  Rather than building a custom field on your Account to house the URL of that image, you reference the image by its Salesforce ID.

First, build a SOQL query to retrieve the ID of that Attachment:

SELECT Id FROM Attachment WHERE ParentId = '{pv0}'

Alternately, if you only want to return Attachments that contain .jpg, .gif, or .png in the file name (to indicate that you only want images retrieved), you could use this SOQL query:

SELECT Id FROM Attachment WHERE ParentId = '{pv0}' AND (Name LIKE '%.jpg%' OR Name LIKE '%.gif%' OR Name LIKE '%.png%')

Once you have the query created you need to add the query ID to the button you are using for the solution. You add the query ID by using the QueryID parameter.


Lastly, you reference the Id field in your template, using the IMAGE: prefix:


The image then populates in the merged output file.

To control the file size, use:


  • Was this article helpful?