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, and not 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:



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:

  1. Open the page containing the form, and then click Validate Field Values in the Business Rules pane.
  2. Create a new extension rule.

    Click Create.

  3. Click Edit, then specify the rule's conditions. Click Done when you're finished.

    You create conditions for validation rules using the standard condition builder, or you can click Use Advanced Expressions to use the advanced expression builder if you want to create more complex conditions.

    For this rule, we want to create two conditions: the Job Role must be 'Project Manager', and the value for Head Count must be greater than 1000. The rule will be applied when both these conditions are met:



  4. Specify the message details.

    When the conditions are met, we want the warning message "Update budget" displayed under the Budget Amount field in the form.

    1. Click + Message.
    2. Type the message texts in the Summary and Details fields.

      You use these two fields to enter the text for the message.

      • Summary. The Summary text is displayed in the title of a message dialog. The text in the Summary field is not displayed on the page if you are using an inline warning, but it's still a required field.
      • Detail. The Detail text is the actual text message. This text is displayed inline in the form if you are displaying an inline warning, and in a message dialog if it's not displayed inline.

      Your message text can be a simple string, like "This number is invalid", or you can write more targeted messages by passing field values and context parameters into the message. For example, you could add something like this in the Detail field: [[ Restricted feedback applies to ${$fields.PersonName.$value()} who is part of ${$objectContext.Department}}. Select someone from the department without feedback restrictions.]]



    3. Select the Warning in the Severity dropdown menu.

      The Severity menu contains the following options:

      • Error. Choose this when there is some data that the user must correct before they can submit the form. This is the highest severity level.
      • Warning. Choose this to call attention to a field, for example, if you want to let a user know to check data that was entered. A warning message won't prevent the user from interacting with the page.
      • Info. Choose this for messages that are only informative.
      • Confirmation. Choose this for messages that confirm an operation or task was completed. This is the lowest severity level.
    4. Select the field where you want the inline message displayed in the Target Fields dropdown menu.


      If you do not select a target field, and the form contains only one editable field, the message is automatically applied to it.

      Note:

      A message is not displayed inline when:

      • You do not select a target field, and the form has multiple fields.
      • You select more than one target field.

      If you want messages displayed in a dialog box instead of inline, a message component in the page needs to be manually configured to handle the messages.

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.