# Workflow Examples

## Example 1 – sequential routing

Here is a diagram:

![](https://4181436240-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-GhlU_QaD6nbLAbaJI%2F-M-alPN8d1D34qhAi5W6%2F-M-alqOrAgesqgRfFRGV%2Fimage.png?alt=media\&token=abf9140f-22fa-4157-b583-1357e8e158da)

The trigger which starts a new CASE is 'Add Person'

There is 1 place:

* P1

There are 2 transitions:

* T1 (Add Person Address), Type=User
* T2 (Update Person Address), Type=User

There are 4 arcs:

* Start -> T1, Inward, Sequential,
* T1 -> P1, Outward, Sequential
* P1 -> T2, Inward, Sequential
* T2 -> End, Outward, Sequential

## Example 2 – conditional routing with a timed split

Here is a diagram:

![](https://4181436240-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-GhlU_QaD6nbLAbaJI%2F-M-alPN8d1D34qhAi5W6%2F-M-alxcJscbQb3THRmHx%2Fimage.png?alt=media\&token=e8960953-aa01-41b9-8713-7ae9ca99ae49)

The trigger which starts a new CASE is 'Add Person'

There is 1 place:

* P1

There are 3 transitions:

* T1 (Add Person Address), Type=User
* T2 (Update Person Address), Type=User
* T3 (Delete Person), Type=Timer (1 hour) – must be no user dialog

There are 6 arcs:

* Start -> T1, Inward, OR-Split (Implicit)
* Start -> T3, Inward, OR-Split (Implicit)
* T1 -> P1, Outward, Sequential
* P1 -> T2, Inward, Sequential
* T2 -> End, Outward, OR-Join
* T3 -> End, Outward, OR-Join

If T1 is not fired within the time limit, T3 will be fired instead. Whichever of T1 and T3 is fired first will cause the other to be cancelled.

Expired items can be identified by running script **workitem(timeout).php** as a cron job at timed intervals.

## Example 3 – parallel routing

Here is a diagram:

![](https://4181436240-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-GhlU_QaD6nbLAbaJI%2F-M-alPN8d1D34qhAi5W6%2F-M-am-QlE3zLcGmP35n8%2Fimage.png?alt=media\&token=f8a3d1e8-c34f-49b4-aa7b-c073b8cc0c0f)

The trigger which starts a new CASE is 'Add Person'

There are 4 places:

* P1
* P2
* P3
* P4

There are 4 transitions:

* T1 (Add Person Address), Type=User
* T2 (Update Person Address), Type=User
* T3 (Maintain Options), Type=User
* T2 (Update Person Address), Type=User

There are 10 arcs:

* Start -> T1, Inward, Sequential
* T1 -> P1, Outward, AND split
* T1 -> P2, Outward, AND split
* P1 -> T2, Inward, Sequential
* P2 -> T3, Inward, Sequential
* T2 -> P3, Outward, Sequential
* T3 -> P4, Outward, Sequential
* P3 -> T4, Inward, AND join
* P4 -> T4, Inward, AND join
* T4 -> End, Outward, Sequential

## Example 4 – conditional routing with a guard

Here is a diagram:

![](https://4181436240-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-GhlU_QaD6nbLAbaJI%2F-M-alPN8d1D34qhAi5W6%2F-M-am2Hr4R11dmkKV4f2%2Fimage.png?alt=media\&token=34bdb98d-584f-4ca6-a5fd-5b3f1e376c74)

The trigger which starts a new CASE is 'Add Person'

There are 2 places:

* P1
* P2

There are 3 transitions:

* T1 (Add Person Address), Type=User
* T2 (Update Person Address), Type=User
* T3 (Maintain Options), Type=User

There are 7 arcs:

* Start -> T1, Inward, Sequential
* T1 -> P1, Outward, Explicit OR split, Guard= `if (strlen($fieldarray['telephone_no']) < 1) return TRUE;`
* T1 -> P2, Outward, Explicit OR split
* P1 -> T2, Inward, Sequential
* P2 -> T3, Inward, Sequential
* T2 -> END, Outward, OR join
* T3 -> END, Outward, OR join

After transition T1 is executed the workflow engine will examine the 2 arcs for a pre-condition (guard). If this condition evaluates to TRUE then the arc with the condition will be processed and the other arc will be ignored. If the condition is FALSE then the arc without the condition will be processed.

## Example 5 – iterative routing

Here is a diagram:

![](https://4181436240-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-GhlU_QaD6nbLAbaJI%2F-M-alPN8d1D34qhAi5W6%2F-M-am5hwVMF_TBRforZs%2Fimage.png?alt=media\&token=23b673e6-3520-4c19-96b5-98c16f6e360a)

The trigger which starts a new CASE is 'Add Person'

There is 1 place:

* P1

There are 2 transitions:

* T1 (Maintain Options), Type=User
* T2 (Add Person Address), Type=User

There are 5 arcs:

* Start -> T1, Inward, Sequential
* T1 -> Start, Outward, Explicit OR split, Guard= `if (strlen($fieldarray['telephone_no']) < 1) return TRUE;`
* T1 -> P1, Outward, Explicit OR split
* P1 -> T2, Inward, Sequential
* T2 -> END, Outward, Sequential

After transition T1 is executed the workflow engine will examine the 2 arcs for a pre-condition (guard). If this condition evaluates to TRUE then the arc with the condition will be processed and the other arc will be ignored. If the condition is FALSE then the arc without the condition will be processed.



reference: [https://www.radicore.org/demo/workflow/docs/workflow-examples.html](https://www.radicore.org/demo/workflow/docs/workflow-examples.html)
