
Example: Including custom properties in a query
This example shows how to use the query method to retrieve tasks that have custom properties.
For example, you want to search for all of the human tasks in the
ready state that have a custom property, customerID,
with the value CID_12345. The following code
snippet shows the query method call for the query:
query ( " DISTINCT TASK.TKIID ",
" TASK_CPROP.NAME = 'customerID' AND " +
" TASK_CPROP.STRING_VALUE = 'CID_12345' AND " +
" TASK.KIND IN
( TASK.KIND.KIND_HUMAN, TASK.KIND.KIND_PARTICIPATING ) AND " +
" TASK.STATE = TASK.STATE.STATE_READY ",
(String)null, (String)null, (Integer)null, (TimeZone)null );
If you now want to retrieve the tasks and their custom properties,
the query method call for the query looks as follows:
query ( " DISTINCT TASK.TKIID, TASK_CPROP.NAME, TASK_CPROP.STRING_VALUE",
" TASK.KIND IN
( TASK.KIND.KIND_HUMAN, TASK.KIND.KIND_PARTICIPATING ) AND " +
" TASK.STATE = TASK.STATE.STATE_READY ",
(String)null, (String)null, (Integer)null, (TimeZone)null );
The
SQL statement that is generated from this API query is shown in the
following code snippet:SELECT DISTINCT TA.TKIID , TACP.NAME , TACP.STRING_VALUE
FROM TASK TA LEFT JOIN TASK_CPROP TACP ON (TA.TKIID = TACP.TKIID),
WORK_ITEM WI
WHERE WI.OBJECT_ID = TA.TKIID
AND TA.KIND IN ( 101, 105 )
AND TA.STATE = 2
AND (WI.OWNER_ID = 'JohnSmith' OR WI.OWNER_ID IS NULL AND WI.EVERYBODY = 1 )
This
SQL statement contains an outer join between the TASK view and the
TASK_CPROP view. This means that tasks that satisfy the WHERE clause
are retrieved even if they do not have any custom properties.Tip: To improve query performance, you can use the inline
custom properties TASK.CUSTOM_TEXT1 through TASK.CUSTOM_TEXT8. These
properties are stored inline, that is, in the same table as the task
or process instance.