Advanced Merge Fields

Advanced Merge Fields

Table of contents

IF-Else Conditions

You can include special fields in your document that allow you to insert conditions based on specific criteria. Insert conditions to avoid the need to create multiple documents by setting up content that will be updated automatically. For example, when you're creating a letter or an email template, and you want the template to display different things depending on the different field values of your data source, use conditional merge.

Let's consider the following scenario:

You're sending a "Thank You" email to your recipients for attending your company event. You have the mailing list and email template ready, but after reviewing the template, you find that the content needs to be updated based on the gender. In such a situation, set rules and conditions so the template will be updated automatically based on the rules defined. The rules decide what text should appear when the value of the conditions is either "true" or "false".

Supported comparisons

Writer supports the following types of comparisons:

Comparison Operators
does not contain
is (=)
is not (not equal)
greater than (>)
less than (<)
begins with
ends with

Writer lets you insert conditions for mail merge fields, fillable fields, and form fields.

Detailed steps are shown below:

Insert conditions to a merge template

You can use IF conditions in the main body of an email template or a mail merge document for inserting things like “his” or “her”, "Mr." or "Mrs.", “he” or “she”, based on the gender. The IF condition compares two values, then inserts the appropriate text as the result of the comparison.

For example, to update "he" or "she" in the letter, insert the following condition in your template.

This means, if the gender is male, add "he" before the text, otherwise add "she" before the text.

To insert conditions into a merge template,

  1. Click More > Automate tab from your template.  
  2. In the Prepare panel, choose the Merge Template option.
  3. In the Merge Template panel, click on the Conditions link under the Advanced Merge Fields.
  4. Specify the conditions in the Set Conditions popup.
  5. You can also insert multiple conditions. To define multiple conditional fields, click the + icon in the Set Conditions popup.
  6. Click Insert to add the conditional field in your template.

Insert multiple conditions

Insert multiple conditions to your document and easily control how the content is sent to each recipient.

Writer supports two basic types of conditions (AND, OR). The IF condition will embed an AND or OR function, according to the defined criteria.

  • AND condition: If your logic contains an AND condition, then the result returns TRUE if all the conditions are met. Otherwise, the result returns "FALSE".
  • OR condition: If your logic contains an OR condition, then it returns TRUE if any one of the conditions is met; it returns FALSE otherwise.

Suppose you have created a data source with two sets of exam marks. The exam can only be cleared when a student score marks greater than 25 in the first set and greater than 20 in the second set. The students only pass the final exam when both the above criteria are met.

Next, define the conditions in your target document as shown below:

To insert multiple conditional fields:

Click the + icon in the Set Conditions popup. Choose an AND operation or an OR operation between the two conditions as per your needs.

To view the existing conditions in your document, simply hover on the IF part of the inserted condition. You can see the expanded form of the condition. Click to view or edit it to suit your needs.

Edit conditions

Once you have placed the conditions in your document, you can edit them by just clicking on the IF part of the inserted condition.

To edit an existing condition:

  1. Open the document template.
  2. Click on the IF part of the condition that needs to be edited.
  3. A dialog box will follow showing your existing conditions. Change your settings in the Insert condition dialog box and click Update.

Users can edit the pattern of the conditions placed in the document. For example, if the pattern is (1), you can add a new condition by editing the pattern as (1 AND 2). This will insert a new condition with AND conjunction. Click the refresh icon near the text box to update the required pattern.

If the user enters an invalid pattern (for example, (1 AND 2 3)), the actual valid pattern will be retained for that condition.

Preview/Test conditions

Before you email the final shipment to your recipients, make sure to have a preview of every record and test if the defined conditions are working as expected.

Once the merge template is ready with the required text, fields, and conditions, click the Save Settings button from the Merge Template Panel.

To preview merge and test conditions,

  1. Click the Preview Merge button in the Merge using existing data panel. This will open a preview window.
  2. Click on each record from the list and test if the conditions are working as expected.
  3. Click the Back to Editor button to go back to your document and make any updates, if required.
  4. The template is now ready, and you can choose the available output options to send the final shipment to the end-users.

Once you have tested the conditions, you can choose to download, print, or send the document for e-signature. Read more about the output options here.

Next record fields

To fetch data from multiple records you can use the Next Record option in the Mail Merge feature. For example, you're creating a letter or an email to all your customers and you require to say different things in your mail depending on the different values in the fields of your data source. Once you have inserted a mail merge field select the Next Record option and then either copy-paste the same field or insert a new field. Now, the field that you have inserted before Next record will fetch data from the first record and the field inserted after Next Record will fetch data from the next corresponding record. In short, the Next Record field will let you jump over to the next row in your data source. This is especially useful while working on labels or documents with multiple identical fields.

To repeat one record per page,

  1. Open your document.
  2. Click More > Automate > Prepare > Merge Template.
  3. In the Merge Template panel, select your data source and sync it with your target document.
  4. Click on <<Next Record>> button to insert it anywhere in your document.

See Also, Create Merge Labels.

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: