Office assignment on a service is configured through an action in the workflow, but for better application tracking it’s also configured using it’s own event.
Sample office assignment configuration:
```json
[
{
"event": "PAY",
"startState": "PAYMENT_PENDING",
"endStateOne": {
"nextEvent": "ASSIGN_OFFICE",
"stateCode": "PENDING_ASSIGN_OFFICE",
"stateName": "Pending Assign Office",
"breakingAction": null,
"nonBreakingActions": [
{
"args": {
"staticTemplate": {
"en": {
"title": null,
"smsBody": "Dear ${applicantName}, your application for: ${serviceName} with billing number ${billReferenceNumber} has been successfully paid! Paid Fee: ${currency} ${formattedPrice}. Application Number: ${applicationNumber}.",
"subject": "Application Paid",
"emailBody": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n <meta charset=\"UTF-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Ubuntu|Ubuntu:bold\">\n <title>Email Notification</title>\n <style>\n body {\n font-family: Ubuntu;\n margin: 0;\n background-color: #eff1f3;\n padding: 32px 0;\n }\n\n #wrapper {\n width: 719px;\n max-width: 100%;\n height: 100%;\n margin: auto;\n background-color: #fff;\n padding: 40px 0;\n }\n\n #content {\n width: 635px;\n max-width: 100%;\n height: 100%;\n background-color: #eaf4ff;\n margin: auto;\n }\n\n header {\n text-align: center;\n padding: 50px 0;\n }\n\n #main {\n background-color: #fff;\n padding: 48px 48px;\n padding-bottom: 90px;\n }\n\n #main>h1 {\n font-size: 36px;\n font-weight: 500;\n text-align: center;\n }\n\n #main>div#text {\n font-size: 16px;\n font-weight: 400;\n line-height: 1.8rem;\n margin: 0;\n }\n\n #main>#btn-wrapper {\n height: 40px;\n margin: auto;\n text-align: center;\n }\n\n #btn-wrapper>a {\n text-align: center;\n background: #0063cf;\n border-radius: 5px;\n border: none;\n color: #fff;\n width: 100%;\n height: 100%;\n font-weight: 700;\n font-size: 16px;\n text-decoration: none;\n padding: 10px 20px;\n }\n\n #btn-wrapper>p {\n display: block;\n font-weight: 400;\n font-size: 14px;\n text-align: center;\n color: #757c8a;\n margin-top: 30px;\n }\n\n #btn-wrapper>p+p {\n margin-top: 0px;\n }\n\n footer {\n padding: 0px 15px;\n margin-top: 20px;\n padding-bottom: 10px;\n }\n\n footer>p {\n font-weight: 400;\n font-size: 14px;\n }\n\n footer>h5 {\n font-weight: 500;\n font-size: 16px;\n }\n\n .link {\n color: #0063cf;\n }\n </style>\n</head>\n\n<body>\n <div id=\"wrapper\">\n <div id=\"content\">\n <header>\n <img src=\"https://irembo.gov.rw/assets/images/logos/irembo-gov-blue.svg\" alt=\"irembogov-logo\" />\n </header>\n <div id=\"main\">\n <h1>Application Paid!</h1>\n <div id=\"text\">\n Dear ${applicantName},\n <br><br>\n Your application for: <b>${serviceName}</b>, with the following detais has been successfully paid:\n <ul>\n <li>Billing Number: ${billReferenceNumber}</li>\n <li>Paid fee: ${currency} ${formattedPrice}</li>\n <li>Application Number: ${applicationNumber}</li>\n </ul>\n Thank you for using IREMBO!\n </div>\n </div>\n <footer>\n <p>This email message was automatically sent by IremboGov.</p>\n <h5>Need help?</h5>\n <span>Call <span class=\"link\">9099</span>\n - Write to us at <span class=\"link\">support@irembo.com</span><br>\n Or visit our <span class=\"link\">support center</span> for support</span>\n <br><br>\n <span>©2023 IremboGov, All Rights Reserved.</span>\n <p>--- SOCIAL MEDIA ICONS ---</p>\n </footer>\n </div>\n </div>\n</body>\n\n</html>"
}
},
"dynamicTemplate": null,
"notificationType": "STATIC"
},
"actionType": "NOTIFICATION"
}
]
},
"endStateTwo": null
},
{
"event": "ASSIGN_OFFICE",
"startState": "PENDING_ASSIGN_OFFICE",
"endStateOne": {
"nextEvent": null,
"stateCode": "PENDING_OFFICER_PROCESSING",
"stateName": "Pending Officer Processing",
"breakingAction": {
"args": {
"officeId": null,
"officeLevel": "LEVEL_1",
"formFieldKey": "locationOfProcessingSector.id",
"formFieldKeys": null,
"officeAssignmentType": "CODE_FROM_LOCATION"
},
"actionType": "OFFICE_ASSIGNMENT"
},
"nonBreakingActions": null
},
"endStateTwo": null
}
]
```
Above we have 2 events:
- **PAY:** in this event, notice the end state will be `PENDING_ASSIGN_OFFICE` with a next event `ASSIGN_OFFICE`. This means:
- After payment the state will change to reflect the next action which will be to assign the office to the application. Until this action is successful, the application will remain in this state
- The event to assign the office will also be triggered (next events are triggered immediately in the background)
- **ASSIGN_OFFICE**: in this event, the important part is the `breakingAction` which is used to assign an office to an application. The action is identified by the `actionType` which is this case is `OFFICE_ASSIGNMENT`. The action also has arguments:
- `officeAssignmentType`: This will be the type of office assignment to configure. Possible values are:
- `CODE_FIXED_OFFICE`: All applications should be sent to a single office
- `CODE_IN_APPLICATION_OFFICE`: The list of available offices will be provided while applying, and the application will be sent to the selected office
- `CODE_FROM_LOCATION`: There’s a location to be selected while applying, and the application will be sent to an office corresponding to the selected location
- `officeId`: In case the `officeAssignmentType` is `CODE_FIXED_OFFICE` this property will be mandatory and should contain the `id` of the office to assign to applications
- `formFieldKey`: In case the `officeAssignmentType` is `CODE_FROM_LOCATION` either this property or `formFieldKeys` will be required. If there’s one location to select from, this property should contain the field key of the location to be selected.
***Example:*** The service requires to select processing district (`fieldKey`: processingDistrict) and processing sector (`fieldKey`: processingSector). Because these fields will be dropdown selectors with dataset and the application should be sent to the sector, this field will contain:
```json
"formFieldKey": "processingSector.id"
```
- `formFieldKeys`: In case the `officeAssignmentType` is `CODE_FROM_LOCATION` either this property or `formFieldKey` will be required. If there’re multiple locations to select from, this property should contain the field keys of the locations to be selected.
***Example:*** The service can be processed in Rwanda or abroad in embassies. The service requires to select whether to process the application in Rwanda which would in turn require to select processing district (`fieldKey`: processingDistrict) and processing sector (`fieldKey`: processingSector). Or if the application will be processed in Rwandan embassies which would in turn require to select embassy (`fieldKey`: embassy). Because these fields will be dropdown selectors with dataset and the application should be sent to the sector or embassy, this field will contain:
```json
"formFieldKeys": [
"processingSector.id",
"embassy.id"
]
```
- `officeLevel`: This is the level at which to send the application. There’re some services that are processed on multiple levels (Level 1, Level 2, …). Most of the time the initial assignment will be at level 1. Possible values are:
- `LEVEL_1`
- `LEVEL_2`
- `LEVEL_3`
- `LEVEL_4`
- `LEVEL_5`
- …