Skip to main content
Conga Support

Use a Salesforce Attachment as a Conga Template

In addition to pre-selecting a Conga Template, Conga Composer can also gather attachments from the Notes and Attachments object related to the master object from which you are running your Conga Composer solution. This is helpful if there are additional documents that should be included with your merged document. To learn more about this process please review this Conga Blog post under number 2, "Using a Salesforce Attachment as a Conga Template."

For example, you may want Conga Composer to generate a proposal document from an Opportunity record but also need to include the Terms and Conditions document that is stored as an attachment (under Notes and Attachments) on the Opportunity.

Create a SOQL Query to retrieve the attachment(s). The query will look something like this:

SELECT Id

FROM Attachment

WHERE ParentId = '{pv0}'

Reference this query via its ID using the &QVar0Id (Query Variable) parameter. For example:

&QVar0ID=a0Ai0000009jpZH 

The SOQL Query from step 1 will return the ID of the attachment, which we now have available in the Conga Composer button URL to use as a variable in another parameter, &AttachmentID. Reference the Query Variable, as {QVar0}, as the value for the &TemplateID parameter. For example:

&Template=a0Bi000000MrkC8,{QVar0}

Below is an example of what your button URL might look like when the &QVar0Id and &TemplateID parameters are added. In this example, {!Account.Id} is being passed into the pv0 filter of the query in order to retrieve the attachment(s) from the Account record related to the Opportunity. Furthermore, we're using the &QVar0Format parameter to format the output of the results retrieved in the Qvar0 query; this is necessary in situations where more than one attachment may be retrieved.

https://composer.congamerge.com

?sessionId={!API.Session_ID}

&serverUrl={!API.Partner_Server_URL_290}

&id={!Opportunity.Id}

&QVar0ID=a0Ai0000009jpZH

&TemplateID=a0Bi000000MrkC8,{QVar0}

&QVar0Format=10010

&DefaultPDF=1

The above method is supported by both TemplateID and AttachmentID. AttachmentID will simply append the file. TemplateID will process the file.