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)

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)

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

tamplate builder

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 Tamplate Conga Composer

Select template

  • After selecting the file, click on the Preview button.
Preview tamplate Conga Composer

Preview Template

Here is how the generated doc looks for me.

generated doc with embeded customer logo from Account

Generated doc with embedded customer logo from Account.


Conclusion

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 [email protected] or chat with us.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: