NOTICE: You are in the old ClientSpace Help system. Please link to the new ClientSpace Help here https://extranet.clientspace.net/helpdoc/home/ClientSpace.htm

Condition Expressions

Condition Expressions are used in email templates, workflow channels, widget layouts, and custom links. Condition Expressions are used to control when an event or action is triggered.

Condition Expressions use Labels from Display Conditions along with AND, OR, and NOT operators to control precedence and sequence. 

  • The AND operator specifies that all specified conditions must be met for a query to return true. The AND is exclusive. AND narrows a search by telling the database that all keywords used must be found.
  • The OR operator specifies that if one of two or more conditions is met, then the query is true. The OR only needs one data point to be present. OR broadens a search by telling the database that any of the words it connects are acceptable.
  • The NOT operator allows you to exclude items that are not relevant to your search. NOT narrows your search by telling the database to eliminate all terms that follow it.

AND expressions

AND expressions are used when you want to include all conditions. For example, consider an expression that specifies that the month must be January and the day of the week must be a Monday (January AND Monday). This expression specifies that all data points must be present; it is exclusive.

OR expressions

OR expressions are used when you want to find an overlap between items. For example, (January OR Monday) specifies that the day could be in January or could be a Monday of any month. This expression specifies that any data point can be present and is inclusive.

NOT expressions

NOT expressions are used when you are interested in a very specific list by letting you eliminate items that are not relevant. For example, (January NOT Monday) specifies that the day could be in January, but cannot be a Monday.

Where to start

The first step in creating Condition Expressions is to determine your objective. A good place to start is with a flowchart using Yes and No logic. Determine the fields and values and whether the condition is to meet all conditions or just one data point. Next, determine how you want to group the criteria. You then must add the conditions (from within a form) and then determine how to group them using Condition Expressions. The remaining portion of this topic describes and illustrates how to compose Condition Expressions.

Before you can build a condition expression, you must first add the conditions from within a form such as Configure Data Links Details.

1. Add Display Conditions

For forms that offer conditions, when you click Add (lower portion of the form), a row opens where you can assign values to within fields such as Source, Field, Operator, Value, and Label (see the following image). The values must correspond to what is stored in the database. For example, lookups would be the Code value, and for parent form fields, such as Case Type, the value would be the ID of the form.

The following example illustrates two expressions, HOL1 and HOL2. These entries are Display Conditions. When the Condition Expression field is empty, the Display Conditions are processed as ORs. For example, in the following example, there is no Condition Expression. Therefore, HOL1 and HOL2 are processed as ORs. The result would be the match for each condition; it would be all-inclusive (WHERE Holiday Name = Christmas OR Holiday Name = New Year's Day).

2. Add a Condition Expression

But what if you want to treat the Display Condition statements differently? What if OR is not enough? You can use a Condition Expression by referencing the display condition statements (through Labels) and adding the AND and OR operators: (Cond1 AND Cond2) OR (Cond3). With a Condition Expression, you can control how many conditions you use and how they are used.

When building a Condition Expression, you use the condition Label value of the Display Conditions. You can create complex conditions by using unique combinations of the conditions. Condition Expressions can use AND as well as OR conditions.

For example, to trigger a workflow when there is a new training request, the expression could be stated as (CaseTypeTR AND CaseNEW) where:

  • CaseTypeTR: When case type = Training Request
  • CaseNew: When case status = New

Using the Label field, you can combine trigger conditions into more complex expressions. For example: (Condition1 AND Condition2) OR (Condition3 AND Condition4) OR Condition5.

The following example has three Display Conditions: STAT, CITY, GEN. Two of the three Labels are used in the Condition Expression.

  • The (STAT AND CITY) Condition Expression is looking for employees who are married and reside in Sarasota. This result is exclusive.
  • When the three separate conditions (STAT, CITY, GEN) are used without a Condition Expression, the search is for employees who are married, or reside in Sarasota, or are female. The result is inclusive.

 

Order of operation

The order of execution can significantly affect the resulting value. To control order and precedence you use parentheses to group functions. Everything within the parentheses is evaluated first to yield a single value before that value can be used by any operator outside the parentheses. If an expression has nested parentheses, the most deeply nested expression is evaluated first.

When a condition is met, the evaluation ends, using the results of the first successful condition. For (Condition1 AND Condition2) OR (Condition3 AND Condition4) OR Condition5, if the first set (Condition1 AND Condition2) is met, then the remaining OR statements are ignored.

Syntax

You can only use Labels and the AND, NOT and OR operators in your Condition Expression.

The Condition Expression cannot contain SQL keywords. See Exception Log Error.


Condition Expression example

The following example illustrates multiple expressions for filtering attributes of a physical property (structure) and user rights:

  • Is the property owner-occupied?
  • Is the property located in one of the following states: Georgia, Alabama, Arizona?
  • Is the property height in the number of stories greater than or equal to 5?
  • Does the user have the security entity named biz_RequestTypeCategory_Envornmental?


Example

Each expression Label is brief and descriptive: OO, GA, AL, SECenv, 5PLUS, AZ. 

TypeDescriptionLabel
FieldValueExpressiongen_Property.OwnerOccupied Equals YesOO
FieldValueExpressiongen_Property.State Equals GAGA
FieldValueExpressiongen_Property.State Equals ALAL
SecurityEntitySecurity Entity Equals biz_RequestTypeCategory_EnvironmentalSECenv
FieldValueExpressiongen_Property.NumOfStories Greater Than or Equal 55PLUS
FieldValueExpressiongen_Property.State2 Equals AZAZ

Condition Expression example

The Labels are used in the Condition Expression along with the AND and OR operators. Additionally, grouping and nesting control the evaluation.

The following example has two major groupings delineated by sets of parentheses. Within each major group, there is a sub-group, also delineated by a set of parentheses.

(OO AND (GA OR AL)) OR (SECenv AND (5PLUS AND AZ))

First group - the ANDParentheses and groupings

The first grouping has two sets of parentheses: 

  • The first group specifies owner-occupied as OO. You need a set of parentheses for OO. Sub-groups are placed inside the parentheses of the major group.


(OO AND (GA OR AL))

  • Within the owner-occupied group, the location must be GA or AL. You need a second set of parentheses for the locations GA and AL.
(OO AND (GA OR AL))
Second group - the OR

The second grouping has two sets of parentheses:

  • The first group is SECenv. You need a set of parentheses for this major group.


(SECenv AND (5PLUS AND AZ))

  • The second group is the number of stories and location. Place the sub-group within a set of parentheses.
(SECenv AND (5PLUS AND AZ))

The following diagram explains how the sample condition expression is evaluated.

Result

For the expression  (OO AND (GA OR AL)) OR (SECenv AND (5PLUS AND AZ))

  • If the property is owner-occupied and is located in Georgia or Alabama, then the evaluation ends because the condition has been met.
    • The OR portion is ignored.
  • However, if there are no properties that are owner-occupied in either Georgia or Alabama, then the OR expression is evaluated.
    • The OR portion looks for:
      • user view rights to RequestTypeCategory_Environmental
      • and the property must be in Arizona with a minimum height of 5 stories


Summary

The examples provided in this topic use nested groupings along with the AND and OR operators. Keep in mind that your needs may vary. Additionally, plan ahead. Determine your Display Conditions and use brief Labels. After you have defined your Display Conditions, then you are ready to compose the Condition Expression.




NOTICE: You are in the old ClientSpace Help system. Please link to the new ClientSpace Help here https://extranet.clientspace.net/helpdoc/home/ClientSpace.htm