Warm tip: This article is reproduced from stackoverflow.com, please click
oracle-apex oracle-apex-19.1

make a field conditionally required

发布于 2020-04-13 10:43:19

I have an item that is displayed conditionally - based on another item selection. I want to make that item non-required when hidden. What is the best way to do that?

Questioner
Coding Duchess
Viewed
37
Tony Andrews 2020-02-04 01:32

As you have probably found, you cannot just set the dependent item's Required attribute, as this makes it required even when hidden. Instead you can create a Validation of type "Item is NOT NULL" on the dependent item, but with a server-side condition based on the value of the other item.

For example, suppose the first item is P12_JOB and the second is P12_COMMISSION, and P12_COMMISSION is only shown when P12_JOB = 'SALESMAN'. Then this Validation will do it:

enter image description here

As you can see there are various settings available there that you should check are appropriate for you e.g. Always Execute, Display Location.