We talk a lot about one-click solutions over here at the Conga ranch. And with good reason – enterprise software isn’t always sexy, but automating complex business processes to drastically simplify the user experience certainly can be.
One of the user choices that we can automate in the process of streamlining Conga Composer is template selection. Over the years, we’ve seen some of our most savvy customers and partners incorporate varying degrees of Salesforce formula logic to drive Conga Composer’s selection of templates. In this post, I’m here to introduce a few ways for you to do the same.
Using formulas to determine what templates Conga Composer will use in response to business logic can get very technical, but the benefits can be tremendous. Reducing clicks, simplifying user choices, reducing errors, conveniently
bypassing the user interface and supporting users with evolving requirements are all benefits of formula-based template selection. If you’re shooting for those types of outcomes, you’re in the right place.
It’s all about the Template IDs
Conga Composer’s
&TemplateID parameter requires the 15-character ID of a supported template record or a series of 15-character record IDs separated by commas if you’re looking to specify multiple templates.
Example:
&TemplateID=a03E0000008HNSw
&TemplateID=a03E0000008HNSw,a03E0000008HOgx
We can use a few different types of formula logic to provide different value(s) for the &TemplateID parameter on a dynamic basis. Let’s examine five ways of automating template selection for Conga Composer with formulas.
1) Selecting 1 of 2 Possible Templates
Location of Formula |
Logic Used |
What to Predefine |
Custom button |
IF function |
Single template |
If you simply need to select one of two possible templates for a given merge process, this is the best approach. To accomplish this, we’ll insert an
IF function directly into our custom button URL as the value for our &TemplateID parameter. I recommend using the ‘Insert Selected Function’ button when doing this – this will give you a nice blueprint of the required syntax for your function.
Next, we’ll set up our expression and true/false values. The basic idea here is that if a certain condition is true, we’ll return a particular template’s record ID for Conga Composer to use. If it’s not true, we’ll return a different template record ID.
Let’s roll with a very basic example to get a feel for how this works. My Composer solution is for creating and sending contracts from the Opportunity. I have a custom checkbox field on the Opportunity called ‘Includes Special Terms’. If the box is checked, I want Composer to use the contract template that reflects special terms, otherwise use the standard contract template.
When I click this button on an Opportunity record, the IF function will check to see if ‘Include Special Terms’ is checked and then return the appropriate record ID.
2) Selecting One of Many Possible Templates
Location of Formula |
Logic Used |
What to Predefine |
Formula field |
CASE function |
Single template |
If your template selection criteria are any more complex than in the previous scenario, where a single IF function could select one of two possible templates for merging, the best practice will be to use a custom formula field to determine which template Conga Composer should use. This keeps your button URL from devolving into a mess of functions and syntax by performing all of the evaluations in a single formula field, and then simply referencing that formula field in your custom button.
As we can see in the above example, a
CASE function takes up a lot of space in a button URL and is best stored in a separate formula field. Keep in mind that this formula won’t need to be on the page layout if you’re using Salesforce Enterprise Edition or above.
While an IF function can only compare an expression to a single value, CASE functions can provide a different result for a series of possible values. This is a great way to use a picklist as a method of selecting a template for Conga Composer.
Expanding upon the previous use case of creating contracts from an Opportunity, let’s say I want to use the standard ‘Type’ picklist on the Opportunity’s related Account to drive my template selection formula. Depending on the type of the organization, we’ll assign a different contract template for Conga Composer to use.
First, we’ll create a new formula field on the Opportunity and make sure it has a return type of ‘text’. This is crucial – the eventual result for our &TemplateID parameter will be a 15-character record ID text string, so the return type needs to be ‘text’.
Next, we’ll insert the CASE function into our formula.
Finally, we’ll fill in the expression with a reference to our ‘Type’ picklist from the Account and then add our expected values and results.
Let’s decode the above screenshot. If the Account Type is ‘Commercial’, this formula will return the first template ID highlighted in yellow. If the Type is ‘Government’, it’ll return the template ID in green. If it’s ‘Nonprofit’, it returns the third template ID in red. Finally, CASE functions provide an ‘else result’ that is returned if the expression (in this case, our Type picklist) doesn’t match any of the specified values. I’ve highlighted this in purple and used the template for ‘Commercial’ accounts as my ‘else result’. This assumes that my commercial contract template is the generic template used for all other possible scenarios, but you might want to select a unique template as an ‘else result’. It just depends on the requirements at hand.
3) Selecting Multiple Templates in a Predefined Order
Location of Formula |
Logic Used |
What to Predefine |
Formula field |
Series of IF functions |
Multiple templates |
Using a series of IF functions in a formula field is a great way to approach Conga Composer solutions that use more than one template. Using this method, you can set up a list of templates that will be merged in a predefined order. These can either be converted into a single output file or merged independently as separate outputs.
To do this, we’ll start with the logic of a single IF function before replicating and modifying the criteria for however many templates we might include in a merge process. We can use the following formula to dynamically assemble a contract with or without a cover letter, that may or may not accommodate special terms and will include terms and conditions relevant to either domestic or international agreements. Pretty good for one little formula!
Let’s deconstruct the above example. In the first IF function, we’re referencing a custom checkbox field called ‘Include Cover Letter’. If that field is checked, we’ll return the record ID of a cover letter template. It’s important to take note of that little comma at the end of the record ID on the first line. We need to be conscious of how we’re going to assemble a particular value to provide for our &TemplateID parameter, so if there will be multiple template IDs, they’ll need to be separated with commas.
In the second IF function we’re also looking at a checkbox – the same ‘Include Special Terms’ field that we used in the very first example. If it’s true, we’ll return the record ID of our contract template that includes special terms. If not, we’ll use the standard contract template. Keep in mind that we’ve put a comma at the end of each of these possible ID values in anticipation of a possible third template.
In the third and final IF function we’re referencing the related Account’s ‘Billing Country’ to see if it has a value of ‘USA’. If it doesn’t, we return the record ID of a template that contains terms and conditions for international agreements. If it does, then we return the record ID of a template with terms for domestic deals. Notice that there aren’t commas present at the end of either record ID because either of these templates would be the final ID in a string of three possible template IDs.
Phew! With all that logic out of the way, here’s the result:
In this case, three template IDs have been correctly strung together based on our formula logic. The cover letter template is highlighted in yellow and the contract template with special terms is highlighted in purple (both included because their relevant checkboxes are checked), and the terms and conditions for domestic agreements is included as the final template ID because our related Account has a Billing Country of ‘USA’.
Back in our Conga Composer button URL, we’ll simply reference this formula’s merge field and we’re good to go.
Pro Tip: If you want to give users the option of reordering templates that are predefined by a formula, you can include the
&SelectTemplates parameter in your Conga Composer button URL.
4) Selecting Multiple Templates with More Flexible Logic
Location of Formula |
Logic Used |
What to Predefine |
Formula field |
Series of IF and CASE functions |
Multiple templates |
Using this approach, we can use a series of IF and CASE functions in a formula field to apply increasingly complex business logic when selecting templates for Conga Composer. This is very similar to the previous example except that we’ll be using a mix of IF and CASE functions to assemble a list of multiple template IDs.
We’re using some familiar logic for this new formula that includes both IF and CASE functions. This is identical to the previous example except that we’re now using a CASE function to select our main contract template depending on the related Account’s Type.
5) Selecting Templates with Complex Criteria Using AND/OR Logic
Location of Formula |
Logic Used |
What to Predefine |
Formula field |
IF, CASE, AND and OR functions |
Single or multiple templates |
All of you formula wizards are probably wondering “why the heck hasn’t he mentioned AND/OR functions yet?” Astute observation, fellow formula wizards – I’ve saved the best for last.
AND/OR functions allow you to incorporate even more variable combinations when determining what templates should be used by Conga Composer on a dynamic basis. AND functions will evaluate multiple logical statements to see if all of them return true. Meanwhile, OR functions evaluate multiple logical statements to see if any of them return true.
The use of these functions open up some serious doors when it comes to accommodating complex logical criteria for template selection. Sticking with our tried-and-true use case for contracts, here’s an example of how you might include AND/OR functions:
At the risk of transitioning to complete nerd-speak, let’s break down the above formula. In the first IF function highlighted in yellow, we’ve nested an AND function to see if the ‘Include Cover Letter’ checkbox is checked and the related Account’s ‘Billing Country’ is not ‘USA’. If both are true, then we return the record ID of a cover letter for non-U.S. contracts. If either of those conditions aren’t met, then another AND function nested within an IF statement can check to see if the cover letter checkbox is checked and the billing country is ‘USA’ and return the record ID of a cover letter for U.S. contracts. If the ‘Include Cover Letter’ checkbox isn’t checked, we simply return null, represented by a set of double quotations.
Next, we’re using a CASE function highlighted in green to check the related Account’s ‘Type’. If it’s either ‘Government’ or ‘Nonprofit’, we’ll return the record ID of our institutional contract template. If it’s anything else (assuming there are only 3 possible values in our Type picklist), we’ll return the record ID of our commercial contract template.
Finally, we’ve nested an OR function within an IF function (highlighted in blue) to evaluate the related Account’s ‘Billing Country’. If it’s ‘USA’, ‘Canada’ or ‘Mexico’, we’ll return the record ID of our terms and conditions template for agreements in the Americas. If it’s anything else, the function will return the record ID of our overseas terms and conditions template.
And there you have it – five ways to automate template selection for Conga Composer with formulas. When it comes to formulas, please keep in mind that there are usually a variety of ways to accomplish the same result. I didn’t even talk about using
logical operators (incredibly useful) and the examples described in this post are meant to act as an introduction to dynamic template selection, not as literal solutions.
Have you used formulas to drive template selection? Or even to automate other aspects of Conga Composer? We’d love to hear your experience and thoughts in the comments. Until next time!