You can use a Salesforce formula field (in this example a CASE function) to determine which template is used in the merge process.
The CASE function will evaluate some field - for example, Opportunity Stage - and based on the value of that field will return the appropriate template ID. This template ID is then passed to the TemplateId parameter in the Conga Composer button/link URL to select the appropriate template. Start by building a formula field (text output) on your master object. Use the Advanced Formula tab to insert the CASE function. A Case statement is an extended If statement where the expression indicates what field you want to evaluate, the value is a potential value of that field, and the result is the result you want when that field equals the value.
For example: CASE( expression, value1, result1, value2, result2, ...,else_ result)
Modify your Case statement to evaluate the desired field and return the appropriate results. In the example below, we evaluate the Opportunity Stage field and return various template IDs accordingly.
After the last value and correlating result, we’ve entered " "
as our else result which populates if none of the other conditions are true.
For example: CASE(StageName, "Prospecting", "a0000000CiPuS", "Value Proposition", "a008000000CZNDh " , "Proposal/Price Quote", "a008000000DiYKJ", "Negotiation/Review", "a08000000E1uXu", " ")
This formula field can be added to the page layout or not; either way, it will always be evaluated and populated, as long as the field-level security is set to "visible" for any user profiles using Conga. Although for template development purposes it may be handy to have it on the page layout to begin with. Also, if you want users to be able to see the else result, you’ll want the field added to the page layout. Finally, users on Professional Edition of Salesforce will have to add the field to the page layout, as field-level security is not an option.
Add this custom formula field into your Conga Composer button URL as part of the TemplateId parameter.
![](/composer/files/202407.1.4/salesforce/158342061/158342059/1/1629874605380/dts1.png)
Conga Composer now looks to the value of your Case statement formula field to see which template ID is designated and then pre-selects that template in the Conga Composer dialog box.
![](/composer/files/202407.1.4/salesforce/158342061/158342060/1/1629874605310/dts2.png)