In business processes you often need to express a deadline, e.g. the customer must have a reply within a week. Sometimes you face delays, e.g. you must wait 4 days before you can take a new corona test.
The Condition and Response rules supports delays and deadlines expressed as ISO 8601 Durations, e.g. P1W meaning 1 week or P4D meaning 4 days.
The Condition between Start and Activity 1 says that Activity 1 can be executed when Start has been executed and 1 day has passed.
In the model below we have modelled a Delay of 4 days after , P4D, the and a deadline of one week, P7D. When the Start activity happens a deadline will be set on the Deadline activity and a delay will be added to the Delay activity, meaning it is not enabled until 4 days has passed.
On the condition, pre-condition and response rules you can enter a delay for condition/pre-condition or deadline for responses in the options panel as illustrated below.
A delay or duration is an expression that is based on the ISO 8601 duration format described below.
When writing duration expressions for delays or deadlines you can use the edit icon to the right of the "Enter Delay" above in order to get help writing duration expressions. The delay/deadline is copied to the Expression below
and the result of the expression is calculated based on the current time. In this way you can experiment writing expressions. P1D means one day ahead, while P1Y means one year ahead:
ISO 8601 Durations
DCR leverages ISO 8601 as a standard for expressing durations.
A duration of 5 days, 3 hours, 4 minutes and 2 seconds can be specified as outlined below.
ISO 8601 Duration P5DT3H4M2S
DCR Flow Editor - Duration
In DCR Flow Editor you can add a duration between two activities. For details about editing flows in swimlane editor read more here.
When adding a duration between activities in the Flow Editor simply drag the clock from to top to the flow. Once done a duration dialogue will be shown as illustrated below:
The Duration (delta attribute) is the actual duration between the activities and will be verified against the semantics of the DCR Process Model.
Durtion From, Duration To and Description (durationFrom, durationTo, and description attributes) are currenty for documentation purpose only. We might later add logic that can add the corresponding delays and deadlines in the DCR Process Model based on theese definitions.
These values are part of the DCR XML Log definition of the flow.
Entering the following values as an example
will provide the following DCR XML Log.
<advance delta="P1D" description="This is a text" durationTo="P1DT20H7M" durationFrom="PT20H" />
ISO 8601 duration picker
Any duration must be entered in an ISO 8601 duration format. In order to make it easier an ISO 8601 duration picker has been added to assist users entering correct ISO 8601 format for the most used time values.
Initial delay and deadlines
If an activity is marked as executed or pending it can also be assigned an initial delay and initial deadline respectively.
If you mark an activiy, e.g. "Initial delay", as executed and set the initial execution time to 1 day ago, "P-1D" in ISO 8601 duration syntax.
Set the initial deadline for the inital deadline activity to 3 days, "P3D".
When you start the simulation you will notice an initial delay and deadline:
Simulation with time
When process models contains delays or deadlines you must choose to simulate with time.
The above model is started on February 18th, 2021 at noon:
Once you execute Start you will notice that a deadline is added to the Deadline activity.
If you look in the Time area in DCR Simulation you will notice that a Delay exits:
If you advance time 4 days you will see that the time is not the 22nd of February and the task list now has the Delay activity enabled:
The definition of a time unit is up to the system using DCR to define. We assume that a time unit of 1 day or 1 hour would make sense in many situations.
You can play with examples of delay and deadlines in models given the examples below:
- Setting a deadline based on a value from WorkZone
- This graph shows how to set the deadline of an activity in a DCR graph based on a value on WorkZone. It seems that you need an intermediate activity for WorkZone to work properly. Notice that we've given the "GetData" activities a data type, a date, so you can simulate the logic in DCR Simulator.
- Computing deadline as an expression
- Setting a deadline can be done entering the specific value, e.g. "P7D" for 7 days or "P5WD" for 5 working days. In some situations you need to be able to compute the deadline based on rules. This example outlines how you can compute based on an Integer or Text, or as a DMN expression.
- Expressing working days
- Using ISO 8601 duration we can express a deadline of 7 days as "P7D". We have extended the expressiveness of durations to support 7 workdays as "P7WD". As a workday excludes Saturday and Sunday the computation will be different. If we execute Start on July 4th, 2022, we will get the 7 day deadline on […]
- Decision Modelling in Timed Dynamic Condition Response Graphs with Data
- This example is presented in the article Decision Modelling in Timed Dynamic Condition Response Graphs with Data presented at the DECH2 workshop associated with the BPM 2021 conference in Rome. A classical way to express business rules is in a procedural manner, e.g. if ... then ... else. However, business people find it hard to […]
- An activity must happen once monthly on the 1st
- Whenever a new month occur you need a specific activity to happen, "Do The Monthly Work". Initially you need to start the process. This is done by executing "A: Start process". This could be done automatically by a Robot user. Once we can set initial delay and deadlines on activities (expected in the summer of […]
- Repeat an activity every week
- Set a deadline based on a duration
- A deadline can be set based on data. You can enter a deadline as a duration and get a deadline for that specific date. The deadline expression Duration gives you the deadline. When we simulate we can set the startdate to November 1st, 2019 and enter a duration of P7D, i.e. 7 days. When the […]
- Set a deadline based on a date
- A deadline can be set based on data. You can enter a deadline as a date and get a deadline for that specific date. The deadline expression (DeadlineDate – now) + P7D gives you the deadline. When we simulate we can set the startdate to November 1st, 2019 and enter a deadline of December 23rd. […]
- Start an activity when a child reaches a certain age
- Working with Syddjurs Municipality we’ve seen examples where certain activities must start when a child reaches the age of 16 or 18. This model outlines how a delay is set so a robotic event is executed when the child reach the age of 16. We assume that the system somehow sets the childs birthday when the process […]
- Put a deadline on hold in building case permits
- We’ve worked with Genoa and Copenhagen Municipalities on building permit process and have found a pattern where a deadline is put on hold while awaiting information from the applicant. Below we outline a graph where the municipality receives a request. Once received they have 60 days to provide an answers regarding the permit. However, if […]
- Absolute time – pattern for exception handling
- This pattern is used to handle missing deadlines. Let us assume we have a deadline of 7 days for some Important Work to be done. We would like to model that after 7 days the manager resolves the issue by Do Something Else. We solve this by including an Exception handling activity which is executed […]
A typical time pattern
Time will typically be used in a pattern where there is a deadline for an activity, expressed as time on a response rule. If this deadline is not met, an exception activity will occur.
If the “must do event” is not completed before 4 time ticks the “Escalate” event will occur as it has the “Automatic” user assigned and is pending. Therefore the Lazy user should execute this event which will (a) exclude the “must do event” and (2) include the “handle escalation” event.
Work days support
With DCR Portal 6.7 it is possible to express workdays.
Using ISO 8601 duration of days is expression as "P7D" for 7 days.
Now it is possible to express duration in workdays as "P7WD" will be 7 workdays. Workdays default excludes Saturday and Sunday from the computation.
Visit the example.
Using a custom CSV file it is possible to extend the holidays to other dates. Using workday computation requires a separate commercial license.
Supporting working days
Different countries have different working days. In order to support this the engine can be extended with a special DLL which calculates the number of working days. For more information please consult the API documentation for TimeManager class.