Logical Expressions

Expression Syntax | User Defined Values | Operators | Wildcard Characters | Functions | Examples | Remarks

Logical expressions are used in combination with merge methods to test data for a true|false result. Typically, a logical expression is used in combination with the 'IF' merge method or may also be used with the 'Compute' merge method.

Expression Syntax

When you create an expression, you can include merge methods and/or fixed values. For example, if an index is called "UnitPrice", and another "Quantity", the expression would be as follows:

<<UnitPrice>> * <<Quantity>>

When you create an expression, enclose strings with single quotation marks:

'<<LastName>>' = 'Jones'

If an index contains any non-alphanumeric characters or starts with a digit or matches (case-insensitively) any of the following reserved words, it requires special handling, as described in the following paragraphs.

And
Between
False
In
Is
Like
Not
Null
Or
True

User-Defined Values

User-defined values may be used within expressions to be compared with index values or method results. String values should be enclosed within single quotation marks (and each single quotation character in a string value has to be escaped by prepending it with another single quotation character). Decimals and scientific notation are permissible for numeric values. For example:

<<FirstName>> = 'John'

<<Length>> >= 50

<<Price>> <= 50.00

Operators

Concatenation is allowed using Boolean AND, OR, and NOT operators. You can use parentheses to group clauses and force precedence. The AND operator has precedence over other operators. For example:

('<<LastName>>' = 'Smith' OR '<<LastName>>' = 'Jones') AND ('<<FirstName>>' = 'John')

When you create comparison expressions, the following operators are allowed:

<
>
<=
>=
<>
=
IN
LIKE

The following arithmetic operators are also supported in expressions:

+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulus)

Wildcard Characters

Both the * and % can be used interchangeably for wildcard characters in a LIKE comparison. If the string in a LIKE clause contains a * or %, those characters should be enclosed in brackets ([]). If a bracket is in the clause, each bracket character should be enclosed in brackets (for example [[] or []]). A wildcard is allowed at the start and end of a pattern, or at the end of a pattern, or at the start of a pattern. For example:

'<<ItemName>>' LIKE '*product*'
'<<ItemName>>' LIKE '*product'
'<<ItemName>>' LIKE 'product*'

Wildcard characters are not allowed in the middle of a string. For example, 'te*xt' is not allowed.

Functions

LEN

Gets the length of a string

Syntax

LEN(StringToBeEvaluated)

Example

Len('<<ItemName>>')

ISNULL

Checks an expression and either returns the checked expression or a replacement value.

Syntax

ISNULL(StringToBeEvaluated, ReplacementValue)

ReplacementValue - If expression is null, ReplacementValue is returned.

Example

IsNull('<<price>>', -1)

SUBSTRING

Gets a sub-string of a specified length, starting at a specified point in the string.

Syntax

SUBSTRING(StringToBeEvaluated, Start, Length)

StringToBeEvaluated - The source string for the substring.

Start - Integer that specifies where the substring starts.

Length - Integer that specifies the length of the substring.

Example

SubString('<<Phone>>', 7, 8)

Examples

Example 1

Name a document "ABC" if the index "CoName" starts with "A", otherwise name it "Misc".

In this example, the result would be "ABC" or "Misc"

Example 2

Name a document "Long Name" if the index "CoName" is longer than 6 characters, otherwise name it "Short Name".

In this example, the result would be "Long Name" or "Short Name"

Example 3

Place a document into a sub folder called "A Names" if the index "CoName" starts with an "A", otherwise place the document in a folder called "All Others".

In this example, the target folder would be "A Names" or "All Others"

Example 4

Place a document into a sub folder called "A or B Names" if the index "CoName" starts with an "A" or "B", otherwise place the document in a folder called "All Others".

In this example, the target folder would be "A or B Names" or "All Others"

Example 5

Name a document using the calculated value of an order by multiplying the quantity by the unit price. Remove any decimal places from the value using the FormatNumber merge method.

In this example, if Qty was 45 then the file would be named "Value_564"

Remarks

None