Purpose of the Short IF Field
Document automation enables you to insert or remove content in your documents to produce a tailored end result.
Syntaq lets you do this in 3 main ways:
- IF Fields;
- ‘Short’ IF Fields; and
- MergeText
This article discusses short IF Fields.
A Short IF Field is useful for inserting short pieces of conditional content. They are also handy for dealing with singular and plural content, e.g. “a Party” and “the Parties”, depending on how many parties are involved.
An ‘open’ Short IF field will have the following syntax:
{ IF "Expression1" Operator "Expression2" "TrueText" "FalseText"}The IF Field compares the two expressions with respect to the operator then inserts the text appropriate to the result of the comparison. That is, if the condition outlined by ″Expression1″ Operator ″Expression2″ is true, the TrueText will be entered into the document. If that condition is not true, the FalseText will be entered instead.
Note: If Expression1 and Expression2 are numeric values they do not need quotation marks around them.
Implementing a Short IF Field
To implement a Short IF Field in your document, follow these steps:
- On the Insert tab in Word, find the Text group and click Quick Parts
- On the drop-down menu, click Field
- In the Field Names list, scroll down and select If
- In the Field codes box, type the expressions, operator, true text, and false text, following the above syntax
- Click OK
If you have done this correctly, the field inserted into your document should appear as though the condition has already been checked. Usually, this will be the FalseText.
For best use with our system, a Short IF Field should include one or more mergefields, linking to fields in an associated online form. You can use a mergefield with form data as Expression1, Expression2, or as part of the TrueText or FalseText.
To add a mergefield into your Short IF Field follow these steps:
- Open your short IF Field by right clicking on it and selecting toggle field codes. (A field in Word is open if the curly brackets containing the field codes are visible)
- Next to the short IF Field, create the desired mergefield (more info)
- Highlight the mergefield and drag (or cut and paste) it inside the short IF Field
Alternatively, you could use the shortcut command for a Word field (ctrl + F9 on PC, fn + cmd + F9 on Mac) and write out the necessary IF and MERGEFIELD codes manually.
Similarly, you can use other Short IF Fields as the TrueText or FalseText to create ‘else if’ logic chains and Boolean and/or logic. For more information see our article.
Operators
For reference, the following table lists all the types of operator that can be used in a short IF Field. Note that there must be a space before and after the operator.
Operator | Description |
= | Equal to |
<> | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
For short IF Fields where two text strings are being compared using the = or <> operators, Expression2 can contain a question mark (?) to represent any single character, or an asterisk (*) to represent any string of characters. Be careful, using an asterisk only works if you are comparing strings that will be 128 characters or less.
Examples
A Basic Example:
{ IF "{MERGEFIELD Field_yn }" = "true" "YES" "NO"}
If ‘Field_yn’ equals ‘true’ then YES will be inserted into the document. Whereas if Field_yn is ‘false’ then NO will be inserted.
Singular and Plural content example:
{ IF {MERGEFIELD Parties_rpt_Count } > 1 "the Parties" "the Party" }
Here, we use the count of the repeat section ‘Parties_rpt’ to determine whether we insert content referring to a singular party or plural parties. Because the expressions being compared are numbers, we don’t use quotation marks.
Multiple Mergefields example:
{ IF "{MERGEFIELD Country_cho }" = "Australia" "" "{MERGEFIELD Country_cho }" }
Here the country selected in the field Country_cho is only inserted in the document if it is not Australia.
Further information on conditional content in document templates can be found here.
For information on creating conditional content in online forms see our knowledgebase articles on the Rules Builder and using Logic & Conditions in the Script Editor
If you have any trouble with Short IF Fields, you can submit a request at the top of this page.
Comments
0 comments
Article is closed for comments.