Set up Merge Rules
While you are sending letters to your mailing list or while printing merge labels, you may need to customize your message based on certain rules. Set up mail merge rules to attain this level of sophistication while sending your documents to multiple users. You can set up rules in your message once you finish creating your data source (mailing list) and inserting mail merge fields in your template. Learn the different types of merge rules that you can use in Writer and how you can set up these rules in the following sections:
Table of contents
You can include special fields in your document that allow you to insert conditions based on a 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".
Writer supports the following types of comparisons:
|does not contain|
|is not (not equal)|
|greater than (>)|
|less than (<)|
Writer lets you insert conditions for mail merge fields, fillable fields, and form fields.
Please find the steps below:
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 set up conditions with mail merge you need to do set up the following:
- Create the target document template.
- Create a data source that has the field values.
- Set up merge fields in the target document.
- Define conditions.
- Preview and test merge.
To insert conditions into mail merge field:
- Open the document template.
- In the Merge Existing Data panel, click on the Insert Conditions link under the Insert Fields header.
- Specify the conditions in the Set Conditions popup.
- You can also insert multiple conditions. To define multiple conditional fields, click the + icon in the Set Conditions popup.
- Click Insert to add the conditional field in your template.
To insert conditions with fillable fields,
- Click More > Insert > Fillable fields. Click here to learn how to use fillable fields in your document.
- Once the document is ready with fillable fields, define and insert the required conditions as required.
- Click the <<Conditions>> options under Advanced fields.
- Define the required condition.
- Click the Preview document button to check how the document will be displayed to the end user.
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 condition 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 scores 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.
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:
- Open the document template.
- Click on the IF part of the condition that needs to be edited.
- 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.
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.
To preview merge and test conditions,
- Click the Preview Merge button in the Merge using existing data panel. This will open a preview window.
- Click on each record from the list and test if the conditions are working as expected.
- Click the Back to Editor button to go back to your document and make any updates, if required.
- 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.
Sort or filter the recipient list before you start Mail Merge in Writer. You can customize your merge and create a filter to include or exclude certain records based on specific criteria. For example, if you want to send offer letters for records with “Designation” specified as “Content Writer” in your data source, you can filter the recipient list based on the above condition and send the email only to these records.
Once you have linked the data source and set up your merge fields, choose to filter the recipient details from the Merge existing data panel.
To filter records,
- Open the target document.
- Click More > Automate > Merge using existing data.
- Under Select Data Source, you will find a Filter icon next to the linked data source file.
In the following Filter Records popup, you can,
- Filter records based on certain conditions.
- Filter records between a particular range.
Filter records based on conditions
If you want to filter records based on certain conditions, use this option. For example, if you want to send the mail to the users with particular criteria, you can specify the condition and click Filter.
Filter records between a particular range
If you want to send the document to a particular range of records from your mailing list, you can use this option.
- Choose the "Between a particular range" option from the filter records popup.
- Set the record range and click Filter.
Mail merges that involve data like addresses, may have empty data for few of its records as they are optional. Previously, a line break was added in the generated document if the merged field is empty, but now you have the option to control the output and reduce the number of blank spaces in your final document. With the advanced option, you can manage to suppress a blank line that appears for every empty field. Instead, if there is no text in the line, the line is not created at all in the merge result. This helps you to avoid multiple blank lines in the document and saves you the trouble of deleting them manually.
To fetch data from multiple records you can make use of 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 theNext 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, 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,
- Open your document.
- Click More > Automate > Document Merge > Merge using existing data.
- In the Merge Existing Data panel, select your data source and sync it with your target document.
- Now in Insert Fields panel, click on <<Next Record>> button to insert it anywhere in your document.