このコンテンツは選択した言語では利用できません。
Chapter 10. Stages
Case management stages are a collection of tasks. A stage is an ad hoc subprocess that can be defined using the process designer and may include other case management nodes, such as a milestone. A milestone can also be configured as completed when a stage or a number of stages are completed. Therefore, a milestone may be activated or achieved by the completion of a stage, and a stage may include a milestone or a number of milestones.
For example, in a patient triage case, the first stage may consist of observing and noting any obvious physical symptoms or a description from the patient of what their symptoms are, followed by a second stage for tests, and a third for diagnosis and treatment.
There are three ways to complete a stage:
- By completion condition.
- By terminal end event.
-
By setting the
AdHocCompletionCondition
toautocomplete
, which will automatically complete the stage when there are no active tasks left in the stage.
10.1. Defining a stage
A stage can be modeled in BPMN2 using the process designer. Stages are a way of grouping related tasks in a way that clearly defines activities that, if the stage is activated, must complete before the next stage of the case commences. For example, the IT Orders case definition described in Chapter 3, Designing a case can also be defined using stages in the following way:
Figure 10.1. IT Orders project stages example

Prerequisites
- You have followed the procedure in Chapter 2, Creating a case to create a new case in Business Central.
- You have started a case definition and defined any other required case nodes described in Chapter 3, Designing a case. Stages must be triggered by another node within a case definition, so at least one other node must be configured in the designer before the stage can be started.
Procedure
-
From the process designer, click
on the left of the palette to open the Object Library. Open the Subprocesses object list, drag and drop an Ad-Hoc node onto the design canvas and provide a name for the stage node.
Define how the stage is activated:
- If the stage is being activated by an incoming node, connect the stage with a sequence flow line from the incoming node.
-
If the stage is instead being activated by a signal event, configure the
SignalRef
on the signal node with the name of the stage that you configured in the first step. -
Alternatively, configure the
AdHocActivationCondition
property to activate the stage when the condition has been met.
- Re-size the node as required to provide room to add the task nodes for the stage.
- Add the relevant tasks to the stage and configure them as required.
(Optional) Configure a completion condition for the stage. As an ad hoc subprocess, stages are configured as
autocomplete
by default, which means that the stage will automatically complete and trigger the next activity in the case definition once all instances in the stage are no longer active.To change the completion condition, select the stage node and open the Properties panel on the right. Modify the
AdhocCompletionCondition
property field in the with a free-form Drools expression for the completion condition you require. For more information about stage completion conditions, see Section 10.2, “Configuring stage activation and completion conditions”.- Once the stage has been configured, connect it to the next activity in the case definition using a sequence flow line.
10.2. Configuring stage activation and completion conditions
Stages can be triggered by a start node, intermediate node, or manually using an API call.
You can configure stages with both activation and completion conditions using free-form Drools rules, the same way that milestone completion conditions are configured. For example, in the IT Orders sample project, the Milestone 2: Order shipped
completion condition (org.kie.api.runtime.process.CaseData(data.get("shipped") == true)
) can also be used as the completion condition for the Order delivery
stage represented here:
Figure 10.2. IT Orders project stages example

Activation conditions can also be configured using a free-form Drools rule to configure the AdHocActivationCondition
property to activate a stage.
Prerequisite
- You have created a case definition in the Business Central process designer.
- You have added an ad hoc subprocess to the case definition that is to be used as a stage.
Procedure
-
With the stage selected on the case design canvas, click
to open the Properties panel on the right.
-
Open the
AdHocActivationCondition
property editor to define an activation condition for the start node. For example,autostart: true
to make the stage automatically activated when a new case instance is started. -
The
AdHocCompletionCondition
is set toautocomplete
by default. To change this, open the property editor to define a completion condition using a free-form Drools expression. For example,org.kie.api.runtime.process.CaseData(data.get("ordered") == true)
to activate the second stage in the example shown previously.
For more examples and information about the conditions used in the IT Orders sample project, see Getting started with case management.
10.3. Adding a dynamic task to a stage
Dynamic tasks can be added to a case stage during run time using a REST API request. This is similar to adding a dynamic task to a case instance, but you must also define the caseStageId
of the stage to which the task is added.
The IT Orders sample case project can be defined using stages instead of milestones.

Use the following procedure to add a dynamic task to a stage in the IT Orders sample project available in Business Central using the Swagger REST API tool. The same endpoint can be used for REST API without Swagger.
Prerequisite
- The IT Orders sample project BPMN2 case definition has been reconfigured to use stages instead of milestones, as demonstrated in the provided example. For information about configuring stages for case management, see Defining a stage.
Procedure
Start a new case using the Showcase application. For more information about using Showcase, see Case management Showcase application.
Because this case is designed using stages, the case details page shows stage tracking:
The first stage starts automatically when the case instance is created.
As a
manager
user, approve the hardware specification in Business Central under MenuTrack Task Inbox, then check the progress of the case. -
In Business Central, click Menu
Manage Process Instances and open the active case instance IT-0000000001
. Click Diagram to see the case progress diagram:
-
In Business Central, click Menu
In a web browser, open the following URL:
- Open the list of available endpoints under Case instances :: Case Management.
Click click the following
POST
method endpoint to open the details:/server/containers/{id}/cases/instances/{caseId}/stages/{caseStageId}/tasks
Click Try it out to complete the following parameters:
Table 10.1. Parameters Name Description id
itorders
caseId
IT-0000000001
caseStageId
Order delivery
The
caseStageId
is the name of the stage in the case definition where the dynamic task is to be created.- body
- This can be any dynamic or service task payload. See Creating a dynamic subprocess using the REST API or Creating a dynamic service task using the REST API for examples.
After the dynamic task has been added to the stage, it must be completed in order for the stage to complete and for the case process to move on to the next item in the case flow.