Dynamic Forms - Part 4: Setting “Subindustry” to be visible and required if “Industry” is selected
In the last step, we set the SharePoint field “Subindustry” to be invisible all the time (we set its “Visible expression” to “false”).
The customer’s requirement is to make that field visible only if the “Industry” field has been selected (it is a lookup field). So, in the next step, we need to change the visibility of the “Subindustry” field based on the selection of the “Industry” field. We will first change “Visible expression” of the “Subindustry” field from “false” (the value we set it to in the previous step) to:
[[Industry]] != ””
This will make the “Subindustry” field visible only if the “Industry” lookup field is populated.
But, since the “Industry” field is enabled only if the “Company” field is not empty, we will need to do the same for the “Subindustry” field, otherwise the form behavior will be weird. So, we will also set the “Enabled expression” of the “Subindustry” field to:
[[Company]] != ""
The last thing we need to do is to set the field “Subindustry” to be required if the field “Industry” has been selected. But here, also, we will need to pay attention to the current value of the company field. So we will set the “Required expression” of the “Subindustry” field to:
[[Industry]] != "" && [[Company]] != ""
This will make the “Subindustry” field required only if both the “Industry” and “Company” fields are filled in:
Setting visible, enabled and required expressions for the subindustry field
If we now check the behavior of our form, we will see that all the customer requirements regarding enabled and visible fields have been met:
Behavior of Subindustry field based on the values of other fields
In less than 5 minutes, just by using skybow Solution Accelerators, we have met the customer’s requirements of making the “Industry” and “Subindustry” fields enabled and visible, based on the values filled into another fields.