Active item & hidden expressions
Last updated
Last updated
The following behaviour is produced in each expression:
Active Item Expression - if the result is true, the item will be active in the form and submits data. If the result is false, the item will not be active and will not submit data.
Hidden Expression - if the result is true, the item will be hidden in the form, but still remains active and submits data. If the result is false, the item will be visible in the form, remains active and submits data.
Let's look at an example for Active Item Expression. I have an element I only want visible when I am fitting screw caps to my bottles. I will use an attribute called Machine Rate, which is a number string attribute. I choose this attribute by clicking on it in from the Attributes panel.
I then added the expression '== 2' to check whether Machine Rate value is 2. Since it is, the form preview calculation resulted in true.
In the above example, since the evaluation resulted to true, the item it applies to is active:
However, if it was false, the item's value will not be submitted, shown below
We apply the same approach to Hidden Expressions. The only difference is that Hidden Expressions do not change if the item is active; only whether it is visible if the expression is true.
In the following example, we want to hide an element that does not need the operator's response, but we do still want the data recorded.
Below is an example using a Data Entry, Evaluate String item to display a description.
This calculation results in a sentence constructed of hard-coded text, the value of another element in the activity ( Bottle Colour) and 2 attributes (Closure type and Machine model). If visible, the operator would see this result:
This element isn't relevant to the operator, but the data does need to be captured. To make sure this element is hidden at all times, we add the following calculation to the Hidden Expression:
Here, we are using the element's own Item Key to say; if the value of this is null OR is not null, then make this element hidden.
This is likely to be your most common calculation for Hidden Expression as it will guarantee that the item is always hidden.
In this screenshot, you can see that item is hidden, but in the following screenshot, you can see that the data from it was still submitted