Example 5

You have a request form that contains three custom fields:

  • Cost (a currency field)

  • Approver (an auto-complete field)

  • Comment (a text field)

If a user provides a value greater than $500 in the Cost field, then you want the Approver and Comment fields to be required before the request can be saved.

To accomplish this, do the following:

  1. Create an advanced "Apply on field change" rule with a dependency on when the Cost field value is greater than "500."

    Rule logic: setFieldRequired(true)

    Result Fields: Approver, Comment

  2. Create the inverse behavior (if the value in the Cost field is not greater than $500, then keep the Approver and Comment fields optional), create an advanced "Apply on field change" rule with a dependency on when the Cost field value is less than or equal to "500."

    Rule logic: setFieldRequired(false)

    Result Fields: Approver, Comment

  3. Changes to the Cost field value trigger the first two rules. But when the request is reloaded (or viewed by someone else in a different session), the results of the rules do not apply. So, you must also create two additional rules that are applied when the request is loaded, as follows:

    1. Create an advanced "Apply on page load" rule with a dependency on when the Cost field value is greater than "500."

      Rule logic: setFieldRequired(true)

      Result Fields: Approver, Comment

    2. Create an advanced "Apply on page load" rule with a dependency on when the Cost field value is less than or equal to "500."

      Rule logic: setFieldRequired(false)

      Result Fields: Approver, Comment