Home » OrclApex » Oracle Apex Client-side Condition JavaScript Expression Example

Oracle Apex Client-side Condition JavaScript Expression Example

In Oracle Apex, we use client-side conditions with dynamic actions to perform a particular action if the client-side condition met and perform another action if the client-side condition does not match. And if your condition depends on multiple items, then you have to use JavaScript Expression type client-side condition. In this tutorial, I am giving some examples of it:

Client-side Condition JavaScript Expression Examples

To specify the client-side condition for your dynamic action, click on the dynamic action of your item, and then select its type to JavaScript Expression for the client-side condition, as shown in the below image:

Oracle Apex client-side condition JavaScript expression.

Usually, for the client-side condition, we require to compare multiple items with a specific value. The following is an example to compare various items using apex.item.getValue() method with JavaScript expression. The True type of dynamic action will execute if the employee status is active, and the employee department is equal to 30:

(apex.item('P2_EMP_STATUS').getValue() === 'ACTIVE' &&
   apex.item('P2_DEPT').getValue() === 30)

If this client-side condition does not match then the False type of dynamic action will execute.

Below is another example to check if the field first name is null or the last name is null:

(apex.item('P2_FIRST_NAME').isEmpty() || 
apex.item('P2_LAST_NAME').isEmpty())

And the following example having both AND and OR conditions:

(apex.item('P2_EMP_STATUS').getValue() == 'ACTIVE' &&
   apex.item('P2_DEPT').getValue() == 30 || 
   apex.item('P2_EMP_DESIG').getValue() == 'ADMINISTRATOR')

Related Tutorial:

2 thoughts on “Oracle Apex Client-side Condition JavaScript Expression Example”

Comments are closed.