A transition has endStateOne (the default) and an optional endStateTwo. endStateCondition lists the conditions for endStateTwo: when all of them are true the application goes to endStateTwo, otherwise to endStateOne. Each condition reads a form field key (or a system key such as applicationState) and compares it with EQ, NEQ, GT, LT, GTE, LTE or CONTAINS.
Approve, or send to inspection first (trimmed)
{
"startState": "PENDING_OFFICER_PROCESSING",
"event": "APPROVE",
"endStateOne": { "stateCode": "APPROVED" },
"endStateTwo": { "stateCode": "PENDING_SITE_INSPECTION" },
"endStateCondition": {
"endStateTwo": [
{ "parameter": "inspectionRequired", "value": "YES", "comparator": "EQ" }
]
}
}
You already met one endStateTwo: on APPLY, a price of 0 goes to endStateTwo (no bill). That one is built in; endStateCondition is how you write your own.
Custom states and other routing constructs
| Construct | What it does | Example |
|---|---|---|
| Custom state | Any state code you name. Give it a stateName in the three languages and an event display name for the officer | PENDING_SITE_INSPECTION |
TRANSITION |
A generic event with your own display name: a step that is not approve, reject or escalate | "Inspection done" from PENDING_SITE_INSPECTION to APPROVED |
nextEvent |
Fires a system event as soon as the state is reached, so system steps chain without a person | PENDING_ASSIGN_OFFICE → ASSIGN_OFFICE; a push state → INITIATE_PUSH |
CANCEL |
Cancels a non-final application. Fired by an officer or authorised agent through the API (needs the cancel permission); usually one CANCEL transition per non-final state | PENDING_OFFICER_PROCESSING → CANCELLED |
SET_APPOINTMENT, SLOT_BOOKING |
Appointment services: a slot is booked, then the application waits for the appointment. Configured with the platform team when the SRD needs it | Driving test booking |
practice: an "inspection required?" branch
- In a practice change request, add a required radio
inspectionRequired(YES, NO).- On the officer approval, keep endStateOne APPROVED and add endStateTwo
PENDING_SITE_INSPECTIONwith the condition above. Move the certificate and approval notification to the step that reaches APPROVED.- Add a
TRANSITIONfrom PENDING_SITE_INSPECTION to APPROVED, ROLE_OFFICER, display name "Inspection done", with the certificate and the notification.- Test both answers. With YES, the officer approves, then sees the "Inspection done" button.
Gotcha · a state nobody can leave
Every state except APPROVED, REJECTED, CANCELLED and PAYMENT_EXPIRED needs at least one way out. A custom state with no outgoing transition traps the application, and the editor does not block it on save. Read each state and name its exits before you test.
Gotcha · only add a condition the SRD asks for
Conditions are evaluated on the stored answers. A wrong value (a label instead of a value, "Yes" instead of "YES") silently sends every application to endStateOne.
A transition has endStateCondition with two conditions for endStateTwo. One is true and one is false. Where does the application go?
B. endStateTwo needs all its conditions to be true. If any is false, the default endStateOne is used.
← B8b · Multi-level approval · B9 · Design the certificate →