This topic walks through the end-to-end process necessary to create a Contracts for Salesforce document, with special focus on the creation of the Word Template used to generate your output agreement. At the end of this configuration process, you will be able to generate an agreement that can be sent for negotiation with Contracts for Salesforce or sent for signature with Conga Sign (or your integrated e-signature solution).

Package Requirements

  • Conga Composer
  • Conga Contracts for Salesforce


This topic assumes a basic understanding of Conga functionality, including how to create:

In addition, this tutorial uses the Composer Lightning Component for document generation.

Building the Solution

Once you are comfortable with the components mentioned above and have configured your Clause Library, follow the steps below to build a solution that generates a Contracts for Salesforce agreement.

  1. Create a Composer Button
    1. Using a Solution record, build a base Composer button for Contracts for Salesforce on the object you have configured to use with Contracts for Salesforce (we will use the managed package Contract Agreement object)
    2.  Ensure that your button includes the required Contracts for Salesforce parameters, &RM=1 and &DataTagEnable=1
    3. Add the button to your object’s Lightning page. We recommend using Dynamic Actions

      You will not have any queries or a Conga Template included in your button now. 

  2.  Create SOQL Queries to Retrieve Managed Clause Data
    1. Create Conga Query records to retrieve Managed Clauses for your document. If using the Contract Agreement, the syntax will be exactly like the example SOQL Query shown in b. aside from the Clause Type filter
    2. Example SOQL Query Syntax: 

      SELECT Id, APXT_Redlining__Text_Rich__c, APXT_Redlining__Order__c FROM APXT_Redlining__Managed_Clause__c
      WHERE APXT_Redlining__Contract_Agreement__r.Id = '{pv0}'AND APXT_Redlining__Clause_Type__c = 'Definitions' ORDER BY APXT_Redlining__Order__c ASC

      Notes on creating queries:

      • Create individual Conga Query records for each Clause Type
      • Filter the SOQL query by Clause Type. Since Clause Types correspond with sections in your agreement, this will allow you to merge clauses into the proper sections in your agreement
      • Replace 'Definitions' with the value of each Clause Type referenced your Managed Clauses
      • Reference the proper lookup object Id in the WHERE clause
      • The Id field must be included for Contracts for Salesforce to function properly
  3. Add the Conga Queries to your Conga Composer button
    1. In your Conga Solution, use the QueryId parameter to add all queries created in step 2 to your button
    2. Give each query an alias that corresponds with the Clause Type that it is pulling. Each alias must be unique. You will use those in the merge field syntax for your Word Template in step 4 below
    3. (Optional) Edit the Conga Query record in a separate tab and add the alias to the title of the query record in order to make it easier to find later. Ex: “My Query Title [queryalias]”
  4. Create a Word Template
    1. Launch the Conga Composer button you created in step 1 by going to a Contract Agreement record and clicking the button. 
    2. In the Composer user interface, click Tools and Settings and then select Template Builder
    3. Expand a query data set for one of the Managed Clause queries created in step 2
    4. Copy the merge field syntax for the rich text field in your query
    5. Paste the merge field syntax into the place in your Word Template where you want those clauses to appear
      • The merge field syntax will be 

      • For more information on TableStart/TableEnd and querying data sets, see Repeating Data in Word
      • For more information on the HTML prefix, see HTML in Word
    6.  Repeat steps c-e as many times as necessary and then save your Word Template
    7. In the Composer user interface, use the Local Template tab to upload your template
    8.  Click Preview to run Composer and merge your agreement using your Word Template
  5.  Create a Conga Template and add it to the Conga Solution
    1. After testing the merge fields, create a Conga Template record
    2.  Turn on Track Changes in Word and upload the Word Template to the Files related list
    3. Associate the Conga Template record to the Conga Composer button using the TemplateId parameter in your button and the Conga Key value for that particular template record
  6.  Convert the Composer button to a Lightning Component 
    1. Reference Composer Lightning Component documentation to configure and use the Lightning Component
    2. Remove the Composer button from the Lightning page

Formatting a Word Template

Use Word auto-numbering to merge clauses into your agreement. For example, if you have a Definitions section that you want to number as 1, 2, 3, etc., your Word Template will look something like this:



  1. {{TableStart:def}}{{HTML:APXT_REDLINING__MANAGED_CLAUSE_TEXT_RICH}}{{TableEnd:def}}


You might also have a Word Template that looks like this:


Terms and Conditions

  1. Definitions
    1. {{TableStart:def}}{{HTML:APXT_REDLINING__MANAGED_CLAUSE_TEXT_RICH}}{{TableEnd:def}}


Sub Clauses

Sub clauses are handled using specific configuration in the Clause Library and nested SOQL queries. Reference Merging Sub Clauses for detailed information on how to do this.