Skip to main content
Conga Support

How to Create IF Fields in a Microsoft Word Template

If Fields / If Statements / Comparison Statements

If fields (also called “if statements”) allow you to compare two values and display document content based on the result of the comparison.  When used in a Word® template, IF fields are especially useful for comparing the values of Composer® merge fields to display an appropriate result. Examples:

  • If an Account’s billing country is not in the United States, display information about international shipping terms.  Otherwise, show domestic shipping terms.
  • If a Contact’s mailing address is blank, show the billing address from his related Account.  If it’s not blank, show the Contact’s mailing address.
  • If an Opportunity’s amount is greater than $10,000, show information about a complimentary service package.  If not, show nothing.
Watch Video

Create IF Statements in Word Template:

 

Best Practice

It is recommended to use traditional merge fields for IF statements. The guidance below uses traditional (not text-based) if statements. For information on traditional merge fields, please see the Composer Release 7 Word Templates Guide.

“Expression1”Operator “Expression2” “TrueText” “FalseText”

Below is a very basic example using merge fields as Expressions.  The single curly braces ({ }) on either end of the IF statement indicate the beginning and end of a traditional merge field when the field codes have been toggled open.

Components of an IF Field

Expression1 & Expression2

Both Expression1 and Expression2 represent values that you want to compare.  For IF fields used with Composer, the expressions are usually merge fields, text strings or numbers.  Expression1 and Expression2 should be surrounded with quotation marks ("").

Operator

A comparison operator.  There will always be a space before and after the operator.

Below is a list of available operators:

TrueText & FalseText

Content that is shown when the comparison is true (TrueText) or false (FalseText).  Each must be surrounded with quotation marks.

Warning

If the content of your TrueText or FalseText in Salesforce contains quotation marks ( “ or ” ), you’ll need to replace those quotes with a pair of single quotation marks (' ' instead of " ").  Otherwise, Word will consider the first quotation mark from your merged data as the end of your text string and the IF statement will not work.

Creating an IF Field - Conga Best Practices

Especially when comparing the values of merge fields, there are a few best practices to follow when creating IF fields in a Composer Word template.  For example, if an Opportunity's Amount is great than $10,000, we want to show information about a complimentary service package.  If it's not, we do not want to show anything. Using this example, we recommend using the following approach:

Procedure Step Result (noted in bold)
Create a traditional merge field with a placeholder name.  «IF_Amount»
Toggle open the field codes. { MERGEFIELD IF_Amount \* MERGEFORMAT}
Delete the contents of the field, entering IF instead. { IF }
Add Expression1 to the IF field. In our example, Expression1 is the Opportunity Amount field. { IF "«OPPORTUNITY_AMOUNT»" }
Insert your Operator. We're using greater than (>). { IF "«OPPORTUNITY_AMOUNT»"  > }
Insert Expression2. Our example is $10,000. { IF "«OPPORTUNITY_AMOUNT»"  > "10000" }
Insert TrueText. Our example is a merge field that displays the details of a complimentary service package. { IF "«OPPORTUNITY_AMOUNT»"  > "10000" "«OPPORTUNITY_SERVICE_PACKAGE»" }
Insert FalseText.  In our example, we don't want to display anything if the Opportunity Amount is less than $10,000 so our FalseText is null, which is a pair of double quotation marks. { IF "«OPPORTUNITY_AMOUNT»"  > "10000" "«OPPORTUNITY_SERVICE_PACKAGE»" "" }

Our finished IF field looks like this:

{ IF "«OPPORTUNITY_AMOUNT»"  > "10000" "«OPPORTUNITY_SERVICE_PACKAGE»" "" }

An IF statement's field code should look like the field above when it is completed. When creating a merge field in Word, the following text will be included at the end of the field by default: \* MERGEFORMAT. This text needs to be removed to ensure the IF statement renders consistently.

Or, if we toggle the field codes closed, it will revert to the merge field with the placeholder name:

«IF_Amount»

For example, let's say the Merge Nation Opportunity has an Amount of $25,000.  Once we merge the template that uses this IF field, our merged IF statement will look like this (showing the results of the «OPPORTUNITY_SERVICE_PACKAGE» field since that is our TrueText:

Now let's say we merge using a different Opportunity called Merge Republic, which only has an Amount of $8,000.  Our result will show nothing ("") since that is our FalseText.