One of the coolest options in the Field Maps Designer form builder is creating conditional-based questions. Their foundation is the conditional statement in the Arcade language, which in this case is created automatically.
First, we need to create the question in our form builder and set it as hidden and Required (Pic. 1).
The Required option isn’t available by default. It must be switched on later. These are the fundamental basics of conditional-based questions because usually, we need to explain something more like If NOT – Why? and so on. Moreover, the Required option shows the stroke 0 symbol visible on the right, which means, that in this case null values are not accepted. The Visible option is always switched on by default. Now we should turn it off as we don’t want to have this question visible when a certain answer isn’t provided.
Next, we must save the form for further use in the Logic section, where the Arcade-based dynamic behavior can be applied to the form.
After that, we can use the “Settings” icon just next to the switched-off Visible option and go straight away to the Launch Arcade Editor button (Pic. 2).
Before you click the Launch Arcade Editor button you should check the generic Arcade formula for your condition, which looks like this:
$feature["OBJECTID"] ==
where the “OBJECTID” is one of the default fields created by ArcGIS Online when the feature-hosted layer is produced.
This formula must change concerning the question we want to base our condition on.
Instead of OBJECTID, you must provide the field name for the question, which defines the created condition. In our case, it will be validation instead (Pic. 3), because we refer to the question directly above.
Next, when you back to the conditional-based question you will spot, that after clicking the “Settings” icon your expression already exists. Because it’s empty we need to enter Edit or Edit Arcade. When clicking Edit you will be redirected to the Expression builder dashboard as shown above (Pic. 2). When clicking “Edit Arcade” you will go straight away to the Arcade editor (Pic. 4).
Your formula should be:
$feature["validation"] == 'No'
When your formula is correct you can click Done. You can alternatively go to the Expression builder dashboard and check your expression (Pic. 5).
Finally, it’s time to check our conditional-based question (Pic. 6)
This is the simplest approach to the Arcade language, which makes the ArcGIS Online dynamic. By simply changing the generic formula, we can prepare the questions based on some specified conditions.
Mariusz Krukar
Youtube: