Set Conditions for a Rule
You determine when a rule is applied by defining a condition. For example, you might create a rule that is applied only when the user is in Canada and has the Manager role.
There are two ways to define the rule's conditions. The first way is to use the basic condition builder to create conditions by selecting criteria and values. This way should be enough to define most conditions. However, if you need to create more complex conditions, and you are comfortable working with expressions, you can click Use Advanced Expression to open the visual expression editor. For more about using the expression editor, see Build Advanced Expressions.
Rules define overrides that are applied to properties only when the rule's conditions are satisfied at runtime. For conditions that use criteria in the User context, like User Authenticated ($user.isAuthenticated
) or Roles ($user.roles
), the condition is met if the logged-in user satisfies the condition.
Note:
When using the Roles criterion ($user.role) in a condition, start entering the role name you need in the Value field. The Value drop-down will display up to 25 matching Oracle Cloud Applications job and abstract roles; keep typing until the desired role displays. (The drop-down will not list any duty roles. If you want to specify a duty role, you can manually type the duty role name in the Value field.)
To create a condition for a rule:
To change the conditions for an existing rule (not a new one), click the rule in the list, then click Edit above the Conditions pane.
If you’re creating a new rule, the next step is to set properties for the fields.
Create Condition Using a Field's Initial Value
When choosing a field in the condition builder, you might see fields listed under both Field Values and under Initial Field Values.
The Initial Field Value is set in the page's metadata. The value might be set by the page developer, but you can also edit the page's metadata in the JSON editor to set a value when extending a page. The initial value set in the metadata isn't affected by changes made by rules or users. If the field is a number and no initial value is set, the value is 0; if the field is a string, the value is an empty string.
The Field Value, on the other hand, is the current value displayed in a page. This value may already have been modified by a rule or user. For example, say the value for the Head Count field is set to 50 in the page's JSON (the Initial Field Value). There might be some rule that sets the field's value (the Field Value) to 60. The Field Value is displayed in the Head Count field in the form. The user may then change the Head Count field to 70 in the form, so the Field Value for Head Count is now 70. The Head Count Initial Field Value, however, is still 50.
Let's look at how to set the Head Count field's initial value in a page, and then add a rule that makes the Head Count field read only when the field's initial value is greater than 100.
In this example, if the rule is applied in the page, the Head Count field is read only.
Build Advanced Expressions
When creating conditions for business rules, you may find your conditions are more complex than you can achieve using the basic condition builder. If this occurs, you can build your own custom expressions to suit your needs.
Note:
If you use advanced expressions in the condition builder, you will no longer be able to use the basic condition builder. If you have already defined some conditions in the basic condition builder, they will be displayed as actions in the Advanced Expression editor.To create an advanced expression:
When you look at your rule, the condition looks like this if it's created using the expression editor: