The where clause in the query function describes the filter criteria
to apply to the query domain.
The syntax of a where clause is the same as an SQL where clause. You do
not need to explicitly add an SQL from clause or join predicates to the where
clause, these constructs are added automatically when the query runs. If you
do not want to apply filter criteria, you must specify null for
the where clause.
The where-clause syntax supports:
The following rules also apply:
- Specify object ID constants as ID('string-rep-of-oid').
- Specify binary constants as BIN('UTF-8 string').
- Use symbolic constants instead of integer enumerations. For example, instead
of specifying an activity state expression ACTIVITY.STATE=2, specify ACTIVITY.STATE=ACTIVITY.STATE.STATE_READY.
- If the value of the property in the comparison statement contains single
quotation marks ('), double the quotation marks, for example, "TASK_CPROP.STRING_VALUE='d''automatisation'".
- Refer to properties of multiple name-value pairs, such as custom properties,
by adding a one-digit suffix to the view name. For example: "TASK_CPROP1.NAME='prop1'
AND "TASK_CPROP2.NAME='prop2'"
- Specify time-stamp constants as TS('yyyy-mm-ddThh:mm:ss'). To
refer to the current date, specify CURRENT_DATE as the timestamp.
You
must specify at least a date or a time value in the timestamp:
- If you specify a date only, the time value is set to zero.
- If you specify a time only, the date is set to the current date.
- If you specify a date, the year must consist of four digits; the month
and day values are optional. Missing month and day values are set to 01. For
example, TS('2003') is the same as TS('2003-01-01T00:00:00').
- If you specify a time, these values are expressed in the 24-hour system.
For example, if the current date is 1 January 2003, TS('T16:04') or TS('16:04') is
the same as TS('2003-01-01T16:04:00').
Examples of where clauses
- Comparing an object ID with an existing ID
"WORK_ITEM.WIID = ID('_WI:800c00ed.df8d7e7c.feffff80.38')"
This
type of where clause is usually created dynamically with an existing object
ID from a previous call. If this object ID is stored in a
wiid1 variable,
the clause can be constructed as:
"WORK_ITEM.WIID = ID('" + wiid1.toString() + "')"
- Using time stamps
"ACTIVITY.STARTED >= TS('2002-06-1T16.00.00')"
- Using symbolic constants
"WORK_ITEM.REASON = WORK_ITEM.REASON.REASON_OWNER"
- Using Boolean values true and false
"ACTIVITY.BUSINESS_RELEVANCE = TRUE"
- Using custom properties
"TASK_CPROP1.NAME = 'prop1' AND " TASK_CPROP1.STRING_VALUE = 'v1' AND
TASK_CPROP2.NAME = 'prop2' AND " TASK_CPROP2.STRING_VALUE = 'v2'"