Using Detail Regions with If Statements.

There are two scenarios to consider when using Detail Regions with IF statements:

  • Scenario 1: All merge fields in the IF statement come from detail data

  • Scenario 2: Only some merge fields in the IF statement come from detail data

In both scenarios, you can use Word merge fields or text-based merge fields, with one exception: the IF statement itself must be a Word merge field. This means that all the fields inside or around the IF statement can be either Word or text-based merge fields, but the IF statement itself must be a Word merge field. Examples using both types of syntax are displayed below.

Scenario 1: All Merge Fields in the IF Statement Come from Detail Data

In Scenario 1, where all merge fields in the IF statement come from detail data, enclose the entire IF statement with TableStart and TableEnd fields and leave them outside the IF statement. Structuring the IF statement this way prevents the IF statement from breaking if your query returns no data.

The example below uses a query with an alias of "Case" and the TableStart and TableEnd Word merge fields are toggled open.

{ MERGEFIELD TableStart:Case \* MERGEFORMAT }{ IF "<<CASE_STATUS>>" = "Closed" 
"<<CLOSE_DATE>>" "Open" }{ MERGEFIELD TableEnd:Case \* MERGEFORMAT }


The same example IF statement is displayed below with text-based merge fields
{{TableStart:Case}}{ IF “{{CASE_STATUS}}” = “Closed” “{{CLOSE_DATE}}” “Open” }{{TableEnd:Case}}


The entire IF statement is enclosed in between the TableStart and TableEnd merge fields because all of the fields (Case Status and Close Date) are retrieved from the Case query.

Scenario 2: Only Some Merge Fields in the IF Statement Come from Detail Data

In Scenario 2, where one merge field in the IF statements is retrieved from detail data, enclose only that field in between the TableStart and TableEnd fields. Additionally, ensure that the field has its own line.

{ IF “<<OPPORTUNITY_AMOUNT>>” > “100000” “This is a big deal Opportunity!  Here are the 
product prices:<<TableStart:OppLineItems>>
<<OPPORTUNITY_LINEITEM_LISTPRICE>><<TableEnd:OppLineItems>>” “” }


The example below displays the same IF statement, but with text-based merge fields.

{ IF “{{OPPORTUNITY_AMOUNT}}” > “100000” “This is a big deal Opportunity!  Here are the 
product prices:{{TableStart:OppLineItems}}
{{OPPORTUNITY_LINEITEM_LISTPRICE}}{{TableEnd:OppLineItems}}” “” }


Consider an example where there are two different detail datasets utilized in a single IF statement. The syntax for this use case is an extension of the example above, where each dataset requires its own line.

{ IF "<<OPPORTUNITY_CLOSEDATE>>" = "<<TODAY>>" "<<TableStart:Case>>
<<Close_Date>><<TableEnd:Case>>"
"<<TableStart:Opportunities>>
<<Close_Date>><<TableEnd:Opportunities>>" }


Nested IF statements in Word, where the else value is another IF statement, work with Conga Composer but are not recommended. Conga Technical Support does not support nested IF statements. It is highly recommended to evaluate nested IF statement logic using Salesforce formula fields instead of IF statements, and then merging the formula field values into the document.

There are other methods to conditionally hide content based on Salesforce data. For more information, see Conditionally Remove a Row in a Table that Has No Data.