This manual describes the use of the Rules Module™ for Adobe® InDesign® with the DesignMerge® software from Meadows Publishing Solutions. The Rules Module, a standard component of DesignMerge Pro and DesignMerge Catalog, provides features to apply powerful, conditional processing (if-then-else statements) while merging or updating content in documents.
Topics Covered in this Manual:
The Rules Module provides features to apply powerful, conditional processing (if-then-else statements) while merging or updating variable content in InDesign documents. With an easy-to-use interface, the Rules Module provides enough power to construct even the most complicated, “nested” statements. In addition, the product supports an extensive list of “qualifiers”, including our unique “List Qualifiers” which greatly simplify constructing a statement’s criteria.
With the Rules Module, DesignMerge Pro and DesignMerge Catalog can apply rules to Variable Links, and can also apply rules to frames and pages, when merging or updating content in an InDesign document. This greatly extends your control over the manner in which data will be placed in your documents. For example, you can use a Link Rule to modify the data or paragraph/character style for a Variable Text Link on a conditional basis. A Frame Rule can delete frames and modify frame attributes, such as the color of the background or frame, for any frame in the document. A Page Rule can apply a parent page, show/hide layers, or omit a page from merged print output. Additionally, if your DesignMerge software installation includes the Scripting Module, then a rule can be set to launch external scripts, which are useful for constructing custom rule actions.
Below is an example of the Rules dialog window where you can set up and test rules for your document, followed by an example of merged results for two different records in a document that is using Rules with DesignMerge Pro.
Example of Rules dialog window where you can set up and test rules
Example of DesignMerge Pro merge results for two different records using rules processing
In the above examples, a Page Rule applied a parent page, a Frame Rule modified the color of the stroke for the Map picture frame, a Link Rule selected a picture for the Map picture frame, and another Link Rule added an appropriate prefix to the customer name.
For step-by-step instructions to set up and use the rules in the example above, see DesignMerge Pro Tutorial #1.
“Rules-based processing” is defined as the ability to perform specific actions based upon the contents of one or more data fields. A simple example would be to add a title (Mr., Ms., etc.) based on the contents of a different data field, such one that indicates gender (M, F). Such a rule might be expressed like this:
If <<Gender>> contains "M", then add the title "Mr. "
else if <<Gender>> contains "F", then add the title "Ms. "
else if... etc.
A more complicated example would be to vary an entire page layout based upon the contents of a different data field, or to omit a document page when a certain condition is met, such as a specific page number. The Rules Module has been designed to handle all of these examples, from simple data modifications to complex page layout alterations.
The following terminology is used throughout this manual to describe the Rules Module.
Expression
Defines a single Condition. An expression defines a single condition, such as [If <<Gender>> contains “M”], which can be evaluated to either true or false.
Criteria
A set of one or more Expressions. Criteria contain one or more Expressions. The Expressions can be inclusive (and), exclusive (or), or any combination. For instance, [If <<City>> is “Chicago” and <<ZIP Code>> is “60173”] is an example of an inclusive Criteria that contains two Expressions. Both of the Expressions must be true in order for the Criteria to be true. If either of these conditions are false, then the entire Criteria evaluates to false.
Action
One or more events to be performed. An Action is a modification that will be made to a piece of data or to a document. Actions can apply to individual Variable Links, frames, or pages within a document.
Statement
A Statement is a combination of Criteria and the associated Actions that will be triggered if the Criteria is true. If the Criteria associated with a Statement evaluates to true, then the Actions associated with that Statement are performed.
For instance, the Statement [If <<Gender>> contains “M”, then Add Prefix: “Mr. “] consists of a single-expression Criteria and a single Action. In this example, if the field identified as Gender contains an “M”, then the Statement would be true. Otherwise, it would be false. If the Statement is true, then the Action is performed. In this case, the text “Mr. “; would be added as a prefix to the data that was currently being processed.
Rule
A set of one or more Statements that are Evaluated and Executed. If the Criteria associated with a Statement is “met” (i.e., the Statement’s Criteria evaluates to true), then the associated Actions are performed (i.e., the Statement is executed). Rules are defined by the user and are specific to each Data Source Definition (DDF).
The Rules Module provides three types of rules: Link, Frame, and Page. Each rule type supports a specific set of Actions, as described below.
Link Rule
A Link Rule is a rule that may be “attached to” any Variable Link that is used in the document. A Link Rule is unique in that only Actions associated with Link Rules can be used to modify data as well as text attributes — they do not modify frame or page attributes (those are handled by the other rule types).
Frame Rule
A Frame Rule is a rule that is associated with a text or a picture frame. Note that a Frame Rule can be “attached” to any frame in a document, but only one rule can be attached to any given frame. A Frame Rule can be applied to any frame, not just frames that contain Variable Links. The Actions associated with Frame Rules are limited to modifying the attributes of the frame, such as background color, shade, stroke, etc. However, if your DesignMerge software installation includes the Scripting Module, you can also launch an external script to perform any other Action you wish.
Page Rule
A Page Rule is a rule that is associated with a document page. Page Rules are evaluated before any merging or other page processing begins. The Actions associated with Page Rules are limited to “Omit Page from Print” and “Apply Master Page”. However, if your DesignMerge software installation includes the Scripting Module, you can also launch an external script to perform any other Action you wish.
It is important to understand the order in which the different rule types are evaluated and processed. The basic process is described below.
A) Page Rules
At the start of a merge/updating process, assigned Page Rules are processed first. This allows the user to establish Actions that may affect the overall document layout, such as applying a parent page.
B) Frame Rules
Once the Page Rules have been evaluated, each frame in the document is processed in turn. Before a frame is processed, DesignMerge checks to see if a Frame Rule has been applied to the frame. If a Frame Rule has been assigned to the frame, that rule is evaluated before the content of the frame is processed. This allows the user to establish Actions that may affect the frame attributes, or even the frame content, such as the case where an Action causes the frame to be deleted.
C) Link Rules
Finally, the content of the frame is processed. This process is slightly different for Text or Article vs. Picture Links. Each process is described in the next section.
The processing for Link Rules may require a bit of explanation. The descriptions below describe how Link Rules are processed for Text, Picture, and Article Variable Links.
Text Link Processing
For Text Links, DesignMerge scans through the story looking for Variable Links. When a Text Variable Link is located, DesignMerge first retrieves the data for the Link. Then, if a rule has been assigned to the Link, DesignMerge passes the data to the Rules Module (along with the name of the rule to be processed). The Rules Module evaluates the rule, and returns the modified data. The modified data is then merged into the Link, and processing continues.
Picture Link Processing
For Picture Links, the process is identical to that of Text Links. However, if a Link Rule has been assigned to a Picture Link, DesignMerge passes the data to the Rules Module where the data is evaluated and modified. The data returned from the Rules Module is assumed to be the name of a picture file to be merged. DesignMerge will scan the normal search paths to try and locate the file.
Article Link Processing
The processing for Article Links proceeds in the same fashion as Text Link Processing. The only difference is that if the Variable Link is defined as an Article Link, the modified data returned from the Rules Module is assumed to be the name of a text file to be merged. DesignMerge will scan the normal search paths to try and locate the file.
This section describes how to create a rule and also how to view or modify an existing rule. To edit a set of rules, you must use the Rules dialog window. To access this dialog window, select Rules from the DesignMerge > Setup menu. This opens the Rules dialog window, as shown below:
Note the Rules dialog window in the picture above displays the rules that exist in the Data Source Definition (DDF) that has been set up for DesignMerge Pro Tutorial #1. You may see a different set of rules when you open the dialog window. To see the same set of rules that are shown in the picture above, open the document that has been set up for Tutorial #1 before you open the Rules dialog window.
The list on the left side of the dialog window shows all of the rules that have been defined for the Current DDF (Data Source Definition). The first column of the list shows the name of the rule, and the second column lists the rule type, as shown in the example below:
To edit or view an existing rule, select it in the list. The dialog window will change to show you how that rule has been defined.
The buttons towards the bottom right side of the dialog window, shown in the picture below, let you manage the rules:
Each button that is available towards the bottom of the Rules dialog window to manage rules is described below.
View
Opens a dialog window with a larger view of all Statements for the currently selected rule. The Statements can then be copied to the clipboard for printing.
New
Creates a new rule.
Delete
Deletes the currently selected rule. You will be warned that the rule is about to be deleted.
Save As
Saves the currently selected rule under a different name. You may also use this button to change the rule type (accomplished by saving the rule with the same name, but changing its rule type).
Rename
Renames an existing Rule.
Save
Saves the changes made to the current rules. Changes are also saved if you click the OK button. However, clicking OK also closes the dialog window. If you prefer the dialog window stay open, select a different rule in the list or click Save.
Test
Tests the rule using live data. This is covered in a separate section of this manual.
Cancel
Discards all changes to the rules (unless the user had previously pressed the Save key), and closes the dialog window.
OK
Saves any changes to the rules and closes the dialog window.
To create a new rule, follow the steps outlined below.
Rules consist of one or more Statements. A Statement consists of a set of Criteria, and a set of Actions. The Criteria are evaluated, and if the result of that evaluation is true, the Actions associated with the Statement are performed.
The Statements box on the Rules dialog window, as shown below, includes all of the options for editing and managing the Statements associated with the currently selected Rule.
Each button in the Statements box is described below:
Add
Adds a new Statement to the list.
Duplicate
Duplicates the currently selected Statement. Note that you cannot duplicate the last Statement in the list (the Default Condition Statement).
Remove
Removes the currently selected Statement (without prompting).
Criteria
Opens the Criteria dialog window to edit the Criteria for the selected Statement.
Actions
Opens the Actions dialog window to edit the Actions for the selected Statement.
There is a Preview area at the top of the Rules dialog window that displays the selected Statement in sentence format. An example is shown below:
Preview All Statements
By default, the Preview area displays the currently selected Statement only. Note that there is a check box option at the top of this area called Preview all Statements. If you check this option, then the preview will show all of the Statements for the rule and will highlight only the currently selected Statement.
When a new rule is created, it will contain a single Statement that refers to something called the Default Condition. The Default Condition is something which is always true. Note that you cannot edit the Criteria for the Default Condition (because it is always true), and the Default Condition Statement is always the last Statement in the list. However, you can edit the Actions associated with the Default Condition (more about Actions later on). Generally speaking, the Default Condition Statement is the one that the rule will “default to” if none of the other Statements in the rule evaluate to true.
When you are working with a new rule, the first thing to do is add one or more Statements to the list. To do so, click the Add button, as shown below:
A new Statement will be added to the top of the list, as shown below:
Continue to click the Add button if you wish to add more than one Statement at a time.
Statements are processed and evaluated in the order in which they appear in the list. You can drag Statements around in the list to change the order in which they are evaluated.
The Stop After First TRUE check box option controls how the Statements are evaluated. If this box is checked, then the Statements are evaluated one at a time until one of the Statements is true. The Actions associated with that Statement are then performed, and processing stops at that point. If none of the Statements in the list evaluate to true, then processing falls through to the Default Condition Statement (which is always true). In this case, any Actions associated with the Default Condition Statement would be performed.
If you uncheck the Stop After First TRUE option, then all Statements are evaluated independently (including the Default Condition Statement). If a Statement evaluates to true, then the Actions associated with that Statement are performed, and processing continues with the next Statement in the rule.
Note that the Statements will change from If/Else to If/If depending upon the setting for the Stop After First TRUE option, as shown in the two examples below:
Criteria are a way of defining whether a condition is true or false. Each Statement includes a set of Criteria, and a set of Actions. When the Criteria for the Statement evaluate to true, the Actions associated with that Criteria are performed.
To edit the Criteria for a selected Statement, follow the steps below.
Clicking the Criteria button on the Rules dialog window will display the Criteria panel on the Edit Criteria and Actions dialog window, as shown below: