Skip to main content

Conditional Merge Fields


Conditional Merge Fields

This article describes how to use IF merge fields in Quote Templates.

Conditional IF Merge Fields in Quote Templates

The number of quote templates your business needs can increase with every new payment method, seasonal discount, and more. Consolidate quote templates by using conditional logic. Based on customer information or charge attributes, you can display different pieces of information on a quote file using IF merge fields.

IF fields contain IF/THEN logic that allows you to customize what is displayed on a customer's quote based on the value of a merge field. For example, you can display the price of a quote item as a numerical dollar amount, or, if the amount is zero, display "FREE".

See Customize Quotes Templates Using Word Mail Merge about inserting merge fields into a quote template.

IF fields have the following limitations:

  • IF fields cannot hide or display specific table columns or rows.
  • IF fields cannot hide or display recursive tables.

Add an IF Field to a Quote Template

IF fields test the value of the merge field, then display different results depending on whether the test result is true or false. The format of an IF field is:

{ IF [Test Condition] [Result Displayed if TRUE] [Result Displayed if FALSE] }

The result displayed can be text, the value of a merge field, a table, or nothing.

For example, the following IF field displays the text "FREE" if the value of Charge.EffectivePrice equals 0. Otherwise, the IF field displays nothing.

{ IF {MERGEFIELD Charge.EffectivePrice \* MERGEFORMAT} = 0 "FREE" "" \* MERGEFORMAT }

To construct this IF field:

  1. Move the cursor to where you want to insert the IF field. Press Ctrl + F9 (or command + fn + F9 on a Mac)  to insert curly braces. Then type IF into the braces:

{ IF } 

IF fields are contained within curly braces. You must insert the curly braces into your invoice template by pressing Ctrl + F9 (or command + fn +F9 on a Mac). Do not manually type the curly braces.

  1. Type a space after IF, then insert the Charge.EffectivePrice merge field. Insert the merge field as described in Customize Invoice Templates Using Word Mail Merge. Do not type the merge field into the curly braces. 

{ IF {MERGEFIELD Charge.EffectivePrice \* MERGEFORMAT}​ }

If the merge field formatting appears different than shown above, you may be in the field result view. To toggle to the field code view, press Alt + F9 (or option + fn + F9  on a Mac).

  1. Type in the rest of the merge field:

{ IF {MERGEFIELD Charge.EffectivePrice \* MERGEFORMAT}​ = 0​ "FREE" "" \* MERGEFORMAT }

You must insert a space before and after the comparison operator. The supported operators are: 

  • =
  • >
  • <
  • =<
  • >=

Example Use Cases 

Example 1: Display Text or a Merge Field Value

The IF field in this example tests the value of Charge.EffectivePrice for 0. If the value equals 0, the test returns true and the IF field displays "FREE" on the Quote. If the value of the field does not equal 0, then the IF field displays the value of the merge field Charge.EffectivePrice on the quote.

{ IF { MERGEFIELD Charge.EffectivePrice } = 0 "FREE" {MERGEFIELD Charge.EffectivePrice \* MERGEFORMAT​} }

Example 2: Display or Hide a Merge Field Value

The IF field in this example tests the value of Charge.Discount for 0. If the value equals 0, the test returns true, and the IF field does not display anything on the Quote. If the value of Charge.Discount does not equal 0, the test returns false, and the IF field displays "You saved"  followed by Charge.Discount.

{ IF {MERGEFIELD Charge.Discount} = 0 "" "You saved {MERGEFIELD Charge.Discount \# $#,##0.00}" }

The IF field displays nothing if the result is two consecutive double quotes ("").