25.1.5 Associating a Table with a Workflow

Associate a workflow with a table or query so activities can reference related row data.

A business process often involves a business entity in your application data model. A workflow definition models that process, and a workflow instance represents one example of it for a particular row in that business entity's table. Many workflow activities reference or modify data in this related business entity row. APEX simplifies this common usage pattern by letting you:
  • configure the Additional Data table and primary key column in a workflow definition, and
  • supply a Details Primary Key value of a corresponding row when creating a workflow instance.

Then, wherever your app starts a new workflow instance, remember to supply the primary key value of the business entity row to which the new flow relates.

This tiny investment of time pays big productivity dividends. Without writing any code or queries, you can reference the business entity row's details anywhere in the flow using any column name. Just use the syntax:
  • &NAME. in text substitutions,
  • :NAME in code and queries, and
  • NAME in activity properties requiring an item name.

For example if your Additional Data table's primary key column is ID, then reference :ID or &ID. or configure ID as the item name providing the value of an activity property.

Tip:

For even more powerful automatic data access in your workflow, change the Additional Data > Type from Table to SQL Query. Your query typically includes a primary table and its primary key column, and can optionally join in any other related data. It must return exactly one row. For workflows accepting a Details Primary Key, your query's WHERE clause can reference its value using the :APEX$WORKFLOW_DETAIL_PK bind variable. Then throughout the workflow you can use &NAME. or :NAME notation to reference the value of any column in your Additional Data query's SELECT list.