For every document template that you define, one or more formatting rules can be applied in combination to any merge field within the template.
The rules are applied in the order that they are listed and each will build on the output of the previous rule. Therefore the contents of the merge field (as it came in from the database) changes as each rule is applied. The output of the very last rule becomes the value(s) shown next to the merge field in the summary screen on document creation.
The rules currently available are:
Aggregation
Change fallback behaviour
Overrides the default behaviour for some fields where ContactsLaw selects a fallback in the absence of a matching result; for example, when a file liaison is not present, the client is used as a fallback.
Group by this field
Causes results whose values for a particular field are identical to be combined into groups. This is only useful for composite fields. You can control whether empty values are grouped together or ignored by this rule. You must add a separate rule to each of the other fields (columns) to indicate how their values should be combined during grouping.
Handle multiple values / Handle grouped values
Many of the dynamic data fields in ContactsLaw are capable of returning multiple results; for example, when a non-specific telephone number is chosen and applied to a contact who has multiple telephone numbers. You can select from a number of methods for handling this situation:
- Prompt for a value - This is ContactsLaw's default behaviour. During document creation, you will be able to select one out of the multiple results for inclusion in the document.
- Join with commas - All values are joined together into a single line with commas.
- Join with grammar - Constructs a natural language list, where the last two items are joined with "and" while all other items are joined with commas.
- One value per line - Each value will appear on a separate line using vertical tabs (SHIFT+ENTER in Microsoft Word and similar).
- One value per paragraph - Each value will appear on a separate line using carriage returns (i.e. new paragraphs).
- Sum values together - Relevant to numerical values only. Returns the sum of all the amounts.
- Always first value - Ignores the multiplicity and always returns a single result.
- Always last value - As above uses the last value in the list.
- Count number of values - Ignores the values themselves and simply provides a count.
- Number in sequence - Replaces the actual values with numbers to indicate their order. This is useful for creating numbered lists of items.
Join values together / Join grouped values together
In cases where multiple results are returned, you can use this rule to join those results together using a particular separator; this might be a carriage return, space, tab, semicolon, etc.
Limit results
This rule allows you to place a cap on the number of results that can be returned for a particular field. For example, you may have built a template which only has provision for two contacts in a particular role. To use the rule, you simply indicate the maximum number of results.
Limit results per contact
This rule is useful for fields belonging to roles; it allows you to ensure that although you desire multiple results, you only want a fixed number of results from each contact in that role. For example, the carbon copy role on correspondence may return several contacts, but you may desire only a single e-mail address from each matching contact. To use this rule, simply indicate the desired number of results (usually 1).
Specify value by number of results
Use this rule to pluralise words; you can provide singular and multiple nouns. You can also use this rule to dynamically add text in situations where the number of results is significant.
Specify value for multiple results
Use this rule to insert text if 2 or more results are returned for the field. If there are fewer than 2 results, the value remains untouched.
Specify value for no results
Use this rule to insert text if no results are returned for the field; this allows you to positively handle a situation where there are no results, without just leaving the value blank.
Take nth result
Use this rule to select a specific result by its position in the list. For example, specify '2' to always select the second result.
Behaviour
Prompt user for value
This rule is only valid for documents generated interactively. It replaces any mapped value with a prompt for the user to enter a value manually during document creation. If the user neglects to enter a value when prompted, the instructional text will not be copied into the document.
Composite
Exclude empty values
It is possible for a field to produce empty results; this happens when the number of results is significant (e.g. rows in a table) but the value associated with the field is blank. Use this rule to exclude empty values. You can specify whether just the field containing the empty value is excluded or the entire result is excluded.
Join to previous field
Used to determine how composite fields are joined together. You can use this rule meaningfully on all but the first component of the field. If you omit this rule, the default joiner (tab) will be used to join the fields together.
Date
Format date
According to established standards such as ISO 8601, all dates and times in ContactsLaw are assembled from the following components:
y - represents the year
M - represents the month
d - represents the day of the month and the day of the week
H - is the hour from 0 to 23
h - is the hour from 1 to 12
m - represents the minutes
s - represents the seconds
t - represents am or pm
Repetition can be used to expand the information shown. For example:
If the date to be displayed is January 1st 1980
d = 1
dd = 01
ddd = Tue
dddd = Tuesday
dddd dd = Tuesday 01
These components are separated using special characters such as / or - or : or a space.
The unformatted dates provided directly from the database are in IEEE format yyyy/MM/dd and optionally include times displayed hh:mm:ss tt. Users can type in their own desired format built from the components above or choose from one of the following defaults:
d MMM yyyy |
1 Jan 1980 |
d MMMM yyyy |
1 January 1980 |
dddd d MMMM yyyy |
Tuesday 1 January 1980 |
d/M/yyyy |
1/1/1980 |
dd/MM/yyyy |
01/01/1980 |
Grammar
Transform word
Applies English language rules to a word or phrase:
Change to plural - Changes a word from its singular form to a plural. Assumes the word/phrase is in singular form.
Add possessive apostrophe - Adds a possessive apostrophe to the end of the word, correctly handling words which end in 's'.
Number
Add ordinal suffix
Adds the appropriate suffix ('st', 'nd', 'rd', 'th') to a number.
Apply number formatting mask
Occasionally it is desirable to format a string of digits in a certain way; for example, ABNs are expressed in groups of three digits, separated by spaces. Number formatting masks are a way of expressing how digits should be interspersed with whitespace or other punctuation.
In a number formatting mask, a 0 represents a digit while any other character is taken as its literal value. e.g. for ABNs, use the mask: 00 000 000 000
Assign to variable
Used in conjunction with formulas (see below) and composite fields. Instead of inserting the mapped value into the field, this rule causes the value to be assigned to a variable which can then be referenced in a formula. Use this rule to create formulas with multiple variables. (Note: You cannot use the name 'x' for a variable here because it is already used to refer to the value for the whole field)
Convert number to words Converts a number into a natural language representation, suitable for cheque printing (e.g. $12,345.25 = "twelve thousand three hundred and forty five dollars and twenty five cents"). The resulting text appears in lowercase.
Convert words to number
Uses natural language rules to convert various text-based representations of numbers into a numerical form that can be used in formulas, summations, or be formatted into a different style. Supported forms include amounts expressed in words (e.g. 'three thousand, two hundred and fifty one') and ordinals (e.g. '3rd' or 'ninety-sixth'). You can specify whether the words 'dollars' and 'cents' are expected to appear in the input.
Define a constant
Used in conjunction with formulas (see below), this rule allows you to define a short name for a value that you intend to refer to in a formula. Avoids repetition if the same value is referenced multiple times, and also makes it easier to change the value without having to change the formula.
Evaluate formula
Allows you to apply a simple mathematical/date formula to the value of the field, which is accessed through the variable 'x'. For example, you could add a number of days to a date value using the formula: AddDays(x, 3)
Format number
Allows you to express a number in a specific format; for example, to a particular number of decimal places, with or without the currency symbol, etc. Number format string can take one of two formats:
- {Letter}{Number} (e.g. N2) - Specifies a built-in number style with a particular number of decimal places. You can use N for numbers, C for currency or P for percentage (multiplies by 100). For full details, see this article.
- Custom format string (e.g. #,##0.00) - Gives you complete control over the number format, including which digits must be included, whether to use the thousands separator, how negative numbers and zeroes differ from positive numbers, etc. For full details, see this article.
Pad with leading zeroes
Sometimes it is desirable for a numeric value to always occupy a certain number of digits, even if it is a small value. This comes into play with cheque numbers, serials, etc. Specify the minimum number of digits in order to use this rule.
Phone
Format phone number
ContactsLaw stores telephone numbers unformatted and in a form relative to the location of the practice. You can reformat any telephone or fax number into the desired style depending on its application:
- Extension - If the telephone number is an internal extension, it will be shown as such. Local, domestic and international numbers are expressed in their most simplified form.
- Local - Extensions are expanded into local numbers. Domestic and international numbers are expressed in the most simplified form.
- Domestic - Extensions and local numbers are expanded into domestic numbers. International numbers remain unchanged.
- International - All numbers are expressed in international form.
Rich text
Handle rich text
By default, ContactsLaw will merge composite mappings containing rich text fields (i.e. product descriptions, contact notes, etc) so that the entire span of text is converted to rich text. This makes it easy to concatenate text onto a rich text result while preserving formatting. However, this renders the composite field incompatible with native tables (e.g. Microsoft Word tables).
By using this formatting rule, you can choose to either convert the rich text result to plain text ("Convert to plain text") or override the default merging behaviour ("Don't combine"). This will allow you to use rich text fields in combination with native tables.
Resize image
This rule allows you to change the dimensions of an image (such as the member's signature or practice logo). This can be useful in situations where the image resolution is greater than the desired size. You can specify units for the width and height; cm, mm, in, px (pixels) or pt (points) - if omitted, pixels are assumed. If you omit one of the dimensions, the original aspect ratio of the image will be preserved.
Text
Change character case
You can specify a particular character case for a field, selecting from the following styles:
- Sentence case - The first letter of the first word is capitalised, while all other words appear in lowercase.
- lower case
- UPPER CASE
- Title Case - The first letter of each word is capitalised, except for conjunctions. This format preserves existing internal capitalisation (e.g. acronyms or mixed-case business names), so it will have no effect if the input is already in upper case.
Exclude other values
Use this rule when you are only interested in matching one value. All others will be excluded from the output. For example, you may wish to build a field that ticks a box if a contact has a particular occupation.
Exclude specific value
Use this rule when you want to exclude a particular value. All others will appear as normal. For example, you may desire that a certain word should never show up in a document.
Find and replace text
This rule allows you to perform a basic search-and-replace on the resulting value. The pattern you specify will be replaced by the text of your choice. For example, you may wish to always replace the word 'message' with 'letter' when it appears in a sentence.
By default, this rule matches whole words only (e.g. the word "female" is not replaced if the search pattern is "male"); however, you can exercise greater control over the behaviour of this rule by using regular expressions (see also: registration hint).
Advanced users: When using regular expressions, your replacement text can refer back to groups in the expression. For example, the expression "/Page (\d+) of (\d+)/" could be used in conjunction with the replacement text "There are $2 pages in the document, of which this is number $1." to preserve the page numbers in the original text. |
Insert text after
Use this rule to insert a piece of text at the end of the ultimate value of the field.
Insert text before
Use this rule to insert a piece of text in front of the ultimate value of the field.
Replace empty values
Sometimes, the absence of information warrants an annotation of some sort. If you want to mark the absence of a result with the text of your choice, use this rule. For example, if a date field has no corresponding value, you might wish to make the field read 'undated'.
Replace non-empty values
Use this rule if, rather than caring about the contents of a field, you only care whether it is empty or contains a value. If the field contains a value, it will be overwritten with the text you provide in the rule.
Replace values containing text
This rule has two parts; a value to match and a value that will replace the result with the text of your choice. Use this rule when you want to unify or generalise information. For example, a verbose document description could be shortened if it contained a particular word or phrase.
Sort values / Sort values in descending order
In cases where multiple results are returned for a particular field, you may wish to sort them in either ascending or descending alphabetical order. On composite fields, you can apply this rule to sort by a particular column. The order of this rule in relation to the other rules is significant; ContactsLaw will sort the results after applying any rules which appear before the sorting rule. By changing the order of the sorting rule, you can alter the behaviour of the sort.
In addition to the basic alphabetical sort, you can opt to use natural language sorting rules - with these, numbers expressed as words (e.g. 'first', '1st', 'one', etc) are first converted into their numerical form and then sorted in an order reflecting this.
Escape codes
When building a set of formatting rules, you may find it useful to insert special characters representing carriage returns, tabs and so forth. These are known as escape codes and consist of a backslash character (\) followed by a letter to signify the desired symbol:
- \n inserts a new line (a new paragraph in Microsoft Word, advances to the next row in a table)
- \v inserts a vertical tab (this is akin to the SHIFT+ENTER combination in Microsoft Word)
- \t inserts a tab (advances to the next cell in a table)
- \c inserts a tab inside a table cell (this is akin to the CTRL+TAB combination in Microsoft Word)
|