10. Dynamic Assignment

Smart Form Rendering (Dynamic Dropdowns)

Workingflow implements dynamic form population based on field ID prefixes:

ID Prefix What it Does Value Stored Data Source
user_* Single-select dropdown of users email@example.com users table
users_* Multi-select checkboxes of users email1,email2 users table
role_* Single-select dropdown of roles ROLE_NAME roles table
roles_* Multi-select checkboxes of roles ROLE_1,ROLE_2 roles table

Important: Do NOT define <activiti:value> entries for user_* or role_* fields; they will be ignored/overwritten. The only exception is the role filter hint described below.

Identity Key: For user_ fields, the system uses the Email as the identifier. This is critical because Flowable uses the email string for "My Tasks" matching.

Filtering Users by Role

By default, user_* and users_* fields show all users in the system. If you want to show only users from a specific role (e.g., only managers), add a <activiti:value id="role" name="ROLE_NAME"/> hint to the field.

Example: Single-Select — Only Managers

<activiti:formProperty id="user_approver" name="Select Manager" type="enum" required="true">
    <activiti:value id="role" name="ROLE_MANAGER"/>
</activiti:formProperty>

<!-- The selected manager's email is stored in user_approver, use it for assignment: -->
<userTask id="approvalTask" flowable:assignee="${user_approver}"/>

Example: Multi-Select — Only HR Members

<activiti:formProperty id="users_hrReviewers" name="Select HR Reviewers" type="enum" required="true">
    <activiti:value id="role" name="ROLE_HR"/>
</activiti:formProperty>
Scenario Field Definition
All users (default) <activiti:formProperty id="user_reviewer" type="enum"/>
Only managers Add <activiti:value id="role" name="ROLE_MANAGER"/> inside the field
Only HR members (checkboxes) Use users_ prefix + <activiti:value id="role" name="ROLE_HR"/>

Backward compatible: If no role hint is provided, all users are shown — existing BPMN files continue to work unchanged. The stored value is always the user's email address regardless of filtering.

Built-in Variables (Flowable Extensions)

Flowable provides several built-in variables that can be used in expressions. These are not part of the BPMN 2.0 standard but are Flowable/Activiti extensions.

Variable How to Enable Description
${initiator} <startEvent flowable:initiator="initiator"/> User ID (email) who started the process
${processInstanceId} Always available Current process instance ID
${processDefinitionId} Always available Process definition ID
${executionId} Always available Current execution ID

Note: The ${initiator} variable is the most commonly used. It requires the flowable:initiator attribute on the start event to capture the starter's identity.