For Developers

Embed Image In Conga Document Using Salesforce ID

4 min read
CloudAnswers photo

Have you come across a scenario where you were required to dynamically pull the customer logo from Salesforce Documents or Attachments while creating a proposal, invoice, etc for a customer? This article explains how to do that.

I’m going to demonstrate how we can embed an image uploaded as an Attachment or Salesforce Document into a Conga document. As per the official Conga docs, this approach works with images uploaded as Salesforce Documents or Attachments to a record.

For this article, let’s suppose we want to create a proposal for a customer from a Salesforce Quote. And, we want to dynamically pull the customer logo from the related Account record and embed it into the generated Conga document.

Now, let’s go through each step one by one.

Create A Conga Query

The first step is to create a Conga Query to fetch the Attachment record. Here is the Conga Query which I have set up for this example:

select Id from Attachment where Description = ‘Logo’ and ParentId IN (select AccountId from Quote where Id = ‘{pv0}’) order by CreatedDate desc limit 1

The above query will fetch the most recent Attachment record related to the Account related to the Quote record. And, it has another condition to filter the records by Description field to make sure it pulls the customer logo. The record, Quote in our case, from which we invoke Conga Composer, will replace ‘{pv0}’ with the Id of that record. You can change the where clause as per your need to fetch the correct record. We just need the Id of the Attachment record, so just query that field.

Note: If you copy and paste the above query, make sure your Attachment record’s Description is set to Logo.

Create Proposal Button on Quote Object

In this step, we are going to create a button on the Quote object and add it to the page layout. I have set up the following button for this example and added it to the appropriate page layout.

Create Proposal (Lightning Version)

URL for Salesforce Lightning button

/apex/APXTConga4__Conga_Composer?serverUrl={!API.Partner_Server_URL_290}&id= {!Quote.Id}&QueryId=[Attachment]a1b63000005d8MHAAY&WordStripIfs=1&SC0=1&SC1=SalesforceFile&OFN={!Quote.Name}

The above button works for the Lightning Experience. For Salesforce Classic you would need to set up a different button which looks like as shown below and makes sure this button shows up for users in Salesforce Classic.

Create Proposal (Classic Version)

URL for Salesforce Classic button

/apex/APXTConga4__Conga_Composer?serverUrl={!API.Partner_Server_URL_290}&id= {!Quote.Id}&QueryId=[Attachment]a1b63000005d8MHAAY&WordStripIfs=1&SC0=1&SC1=SalesforceFile&OFN={!Quote.Name}

Let’s Test What We Have So Far

Before we proceed further, let’s make sure we can retrieve the attachment record in the Conga Composer with the Conga Query which we have setup. For that follow the following steps:

  1. Create or go to an existing Account record
  2. Upload a customer logo as an attachment to Account (Tip: You may need to switch to Salesforce Classic to upload the file as an Attachment)
  3. On the Quote detail page, click on the Create Proposal button. This will open Conga Composer
  4. On Conga Composer, click Template Builder under Tools & Settings

If everything is set up correctly, we should see the query result for the Attachment query as shown below

Template Builder

If you were able to see the Attachment record in Template Builder as shown above, let’s go ahead with next steps. Otherwise, revisit the previous steps and make sure everything is setup correctly.

Add IMAGE Tag To Conga Template

In this step, we are going to add the Conga IMAGE tag to a Conga Template and see end result in the generated document. Here is a sample template that we have created for this article.

Note: You can try with the above template or copy and paste the tags from our template into your template.

Now, let’s test the above template in Conga Composer.

  • On Conga Composer, choose the Local Template tab and select the Conga Template as shown below.

Select template

  • After selecting the file, click on the Preview button.

Preview Template

Here is how the generated doc looks for me.

Generated doc with embedded customer logo from Account.


We can use the Conga IMAGE tag to embed images uploaded as attachments to a Salesforce record. We can extend this example to different real-world use cases and the possibilities are endless.

If you need help with Salesforce or have something a little more complex that might require advanced developer knowledge? We can help. Contact us at or chat with us.

Read also

Effective data storage in Salesforce for every business size

Custom domains and free SSL on Sites

CloudAnswers photo

About CloudAnswers

Salesforce apps, powerful components, custom development, and consulting. Our experienced team helps you to create and modify workflow processes in salesforce.

Related Articles

For Developers

Tips for Becoming a Salesforce Developer

Interested in becoming a Salesforce developer? In this blog post Jagmohan has put together his favorite tips and resources to get started in the world of Salesforce development.

April 4, 2024

6 Min Read

For Developers

Designing User Security and Visibility in Salesforce

Trust and security are at the top of Salesforce's priority list. The platform has everything you need if you're looking to construct a robust user security paradigm. However, this security approach has flaws that an attacker can exploit to gain access to your data. The Salesforce Architect has the duty to ensure that these features are set up correctly.

March 16, 2022

7 Min Read

For Developers

Batch Apex Error Event - CloudAnswers Hackathon

A hackathon is an event usually put together by a tech organization. The event brings programmers together over a specific period to collaborate on a project.

June 28, 2021

5 Min Read