This article is to help explain how use boundary events and validation with the Brazos UI Modal coach view.
The Brazos UI Modal control has 4 configuration options that allow you to fire boundary events. These can be found in the "Boundary Event" configuration options for the Modal:
- Fire Boundary Event on Modal Open - fires a boundary event when the modal control is opened and sets the "Action Executed" variable to "TRIGGER"
- Fire Boundary Event on Modal Done - fires a boundary event when the modal's "Done" button is clicked and sets the "Action Executed" variable to "DONE"
- Fire Boundary Event on Modal Cancel - fires a boundary event when the modal's "Cancel" button is clicked and sets the "Action Executed" variable to "CANCEL"
- Fire Boundary on Modal Closed - fires a boundary event when the modal is closed any other way (click on the background, press Escape, or click on the "X" button) and sets the "Action Executed" variable to "CLOSE"
There is only one actual boundary event on the coach for each modal, so if you are firing multiple boundary events for a single modal you must use the "Action Executed" variable to determine which action fired the boundary event. An example of using all the different boundary actions is shown in the Brazos UI Examples Process App.
Note that help text in the Modal control documents the configuration options - hover over the configuration options to display the associated help text.
You can use the Modal Boundary Events to enable validation of data inside the modal.
If you want to trigger a validation error inside the Modal, you can use the 'Error Message on Return from "Done" Boundary Event' configuration option. If this configuration contains a value when the user clicks on the Modal's "Done" button , the value is displayed as an error message and the modal doesn't close. If the configuration is empty or null when the user clicks on the Modal's "Done" button, the Modal will be closed and no message will be displayed.
A common pattern is to associate the configuration option 'Error Message on Return from "Done" Boundary Event' to a variable that's controlled on the server side. This server side variable will control if the modal is closed and the error message that is displayed.
Field level validation using the out of the box coach validation framework does not allow you to keep the modal open and present an error on the field. You can do field level validation with the out of the box validation framework; however, the modal will not remain open after the validation fires. One option is to combine the two approaches and validate at the field level on submission of the coach as well using theError Message on Return from "Done" Boundary Event' while in the modal.
Attached you will find an example that illustrates using Done and Cancel boundary events, 'Error Message on return from "Done" Boundary Event', and out of the box coach validation with a Brazos UI Modal.
To run this example:
- Download the example
- Import into your Process Center and open the example in the Process Designer
- Run the Demo Human Service
- Click the Demo button to open the modal
- In the Modal Text input box
- Leave the input box empty and click Done to see the error generated from the "Error Message on return from 'Done' Boundary Event" configuration.
- Enter text and click Done for no errors.
- Clicking Cancel will clear any text that was entered. This is controled by the "Fire Boundry Event on Modal Cancel" configuration option and the associted server script.
- Click the "Validate Field Inside Modal" button to generate the out of the box coach valication on the Modal Text input box inside the modal.
- To generate an error leave the Modal Text input box in the modal empty.