Display Messages When Conditions Are Met
You use a validation rule to display a message when certain conditions are met. When you create a rule, you define the conditions for when the rule should be applied, and define the message that should be displayed.
Validation rules are set at the object level, rather than for a specific page. This means that when you define a validation rule for a form—for example, a form for editing the BudgetDetails business object—the rule is applied on every page where that form is used and the conditions are met.
Validation rules are particularly useful when you want to display some type of warning message based on data entered in a form. Suppose you want to display a message reminding the user to update the Budget Amount when the Head Count is more than 1000. You can create a rule that checks the value entered in the Head Count field, and display a message like this in the form:
Note:
Validation rules only display messages in forms rendered using the oj-dyn-form
form component. If your application has any forms rendered using the older version of the form component (oj-dynamic-form
), validation rules won't work correctly in those forms.
To check which version of the form component is used in a page, :
- Select the form component to open the component's details pane in the Properties pane.
- Hover your cusor over the component's name to view the Info icon (
), then move your cursor over the icon to open the component's Info popup.
In the example above, the popup shows this form is rendered using theoj-dyn-form
form component.
Create a Rule to Validate a Field
Let's take a look at how to create a rule that works like the example above, displaying a message in a form when the value for the Head Count field is over 1000.
To create the validation rule:
To add a different message to the rule, say a message with different text displayed under a different field, click + Message to create a new message and specify its details.
To check if your rule is working, view the page in Live mode and test the form by entering values to trigger the rule.