Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
In this article, we will show how to make a field mandatory based on the value of another field.
Figure 1: When dropdown "Type" is set to "With Evidence", "Attachment" becomes mandatory field.
There are 2 methods, first is by making use of Section Visibility in Section properties, and secondly, by using beanshell script in one of the fields.
Place the file upload in its own section, configure the section visibility to only show such that when the dropdown value is "With Evidence".
Figure 2: File Upload in its own section
Secondly, set the file upload's validator to mandatory.
In this method, there's no need to have separate sections as validation will take place in the script itself, instead of relying on section visibility's logic.
We will place the script as "Bean Shell Validator" in one of the field. The following sample script is to be put in File Upload's Bean Shell Validator.
In this script, we will obtain the value selected from the dropdown, then based on its value, we will choose to/not to enforce the need for file upload.
You may check out the demo app below for this method.