Chapter 28. Milestones Milestones are a special service task that can be configured in the case definition designer by adding the milestone node to the process designer palette. When creating a new case definition, a milestone configured as AdHoc Autostart is included on the design palette by default. Newly created milestones are not set to AdHoc Autostart by default. Case management milestones generally occur at the end of a stage, but they can also be the result of achieving other milestones. A milestone always requires a condition to be defined in order to track progress. Milestones react to case file data when data is added to a case. A milestone represents a single point of achievement within the case instance. It can be used to flag certain events, which can be useful for Key Performance Indicator (KPI) tracking or identifying the tasks that are still to be completed. Milestones can be in any of the following states during case execution: Active : The condition has been defined on the milestone but it has not been met. Completed : The milestone condition has been met, the milestone has been achieved, and the case can proceed to the task. Terminated : The milestone is no longer a part of the case process and is no longer required. While a milestone is available or completed it can be triggered manually by a signal or automatically if AdHoc Autostart is configured when a case instance starts. Milestones can be triggered as many times as required, however, it is directly achieved when the condition is met. 28.1. Creating the Hardware spec ready milestone Create a HardwareSpecReady milestone that is reached when the required hardware specification document is completed. Procedure In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas and place it on the right side of the Place order end event. Click the new milestone and click the Properties icon in the upper-right corner. Input Hardware spec ready in the Name field. Expand Implementation/Execution and select AdHoc Autostart . Expand Data Assignments , click in the Assignments field, and add the following: Click the Source column drop-down, select Constant , and input org.kie.api.runtime.process.CaseData(data.get("hwSpec") != null) . Click OK . 28.2. Creating the Manager decision milestone This milestone is reached when the managerDecision variable has been given a response. Procedure In the process designer, expand Milestone in the Object Library and drag a new milestone onto the canvas below the HardwareSpecReady milestone. Click the new milestone and click the Properties icon in the upper-right corner. Input Manager decision in the Name field. Expand Implementation/Execution and select AdHoc Autostart . Expand Data Assignments and click in the Assignments field and add the following: Click the Source column drop-down, select Constant , and input org.kie.api.runtime.process.CaseData(data.get("managerDecision") != null) . Click OK . 28.3. Creating the Order placed milestone This milestone is reached when the ordered variable, which is part of the Place order sub-process, has been given a response. Procedure In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas below the Prepare hardware spec user task. Click the new milestone and click the Properties icon in the upper-right corner. Input Milestone 1: Order placed in the Name field. Expand Implementation/Execution and select AdHoc Autostart . Expand Data Assignments , click in the Assignments field, and add the following: Click the Source column drop-down, select Constant , and input org.kie.api.runtime.process.CaseData(data.get("ordered") == true) . This means that a case variable named ordered exists with the value true . Click OK . Click Milestone 1: Order placed and create a new script task. Click the new script task and click the Properties icon in the upper-right corner. Input Notify requestor in the Name field. Expand Implementation/Execution and input System.out.println("Notification::Order placed"); . Click the Notify requestor script task and create a signal end event. Click the signal event and in the upper-right corner click the Properties . icon. Expand Implementation/Execution , click the down arrow in the Signal field, and select New . Input Milestone 2: Order shipped . Click the down arrow in the Signal Scope field, select Process Instance . Click Save . Figure 28.1. Order placed milestone 28.4. Creating the Order shipped milestone The condition for this milestone is that a case file variable named shipped is true . AdHoc Autostart is not enabled for this milestone. Instead, it is triggered by a signal event when the order is ready to be sent. Procedure In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas below the Notify requestor script task. Click the new milestone and click the Properties icon in the upper-right corner. Input Milestone 2: Order shipped in the Name field. Expand Implementation/Execution and ensure that AdHoc Autostart is not selected. Expand Data Assignments , click in the Assignments field, and add the following: Click the Source column drop-down, select Constant , and input org.kie.api.runtime.process.CaseData(data.get("shipped") == true) . This means that a case variable named shipped exists with the value true . Click OK . Click Milestone 2: Order shipped and create a new script task. Click the new script task and click the Properties icon in the upper-right corner. Input Send to tracking system in the Name field. Expand Implementation/Execution and input System.out.println("Order added to tracking system"); . Click the Send to tracking system script task and create a signal end event. Click the signal event and in the upper-right corner click the Properties . icon. Expand Implementation/Execution , click the down arrow in the Signal field, and select New . Input Milestone 3: Delivered to customer . Click the down arrow in the Signal Scope field, select Process Instance . Click Save . Figure 28.2. Order shipped milestone 28.5. Creating the Delivered to customer milestone The condition for this milestone is that a case file variable named delivered is true . AdHoc Autostart is not enabled for this milestone. Instead, it is triggered by a signal event after the order has successfully shipped to the customer. Procedure In the process designer, expand Milestone in the Object Library and drag a new milestone on the canvas below the Send to tracking system script task. Click the new milestone and click the Properties icon in the upper-right corner. Input Milestone 3: Delivered to customer in the Name field. Expand Implementation/Execution and ensure that AdHoc Autostart is not selected. Expand Data Assignments , click in the Assignments field, and add the following: Click the Source column drop-down, select Constant , and input org.kie.api.runtime.process.CaseData(data.get("delivered") == true) . This means that a case variable named delivered exists with the value true . Click OK . Click Milestone 3: Delivered to customer and create a new user task. Click the new user task and click the Properties icon in the upper-right corner. Input Customer satisfaction survey in the Name field. Expand Implementation/Execution , click Add below the Actors menu, click Select New , and input owner . Input CustomerSurvey in the Task Name field. Select the Skippable check box and enter the following text in the in the Description field: Satisfaction survey for order #{CaseId} click in the Assignments field and add the following: Click OK . Click the Customer satisfaction survey user task and create an end event. Click Save to confirm your changes. Figure 28.3. Delivered to customer milestone The IT Orders case can be closed after all milestone sequences are completed. However, due to the ad hoc nature of cases, the case could be reopened if, for example, the order was never received by the customer or the item is faulty. Tasks can be re-triggered or added to the case definition as required, even during run time.

Commands: