Introduction to Expressions
In addition to deriving values, you can also dynamically hide and show widgets or make them editable/read-only based upon other values.
The best way to illustrate using expressions is with a very simple example:
Example
- Add two Number items to a form.
- Give the first one the caption Amount, and the second one the caption Times five.
- In the second one, add the following expression (note that expressions always have an “=” sign at the start):
=Amount * 5
- Save the form and publish it.
- Download the form to your mobile device.
- Open the form and type 7 into the “Amount” box. You should see 35 appear in the Times five box – the result of
There might be a short delay before it updates as the App waits a short time to make sure you’ve finished typing before it starts calculating.
Try changing the value in Amount. Times five will update accordingly. Try keying a value into Times five. Now change Amount. You should see that Times five no longer updates.
Tip
If the mobile user keys something into the item with the expression, the expression is “overridden” by the keyed information.
You can prevent the mobile user from over-typing the value in an item by ticking the read only option for that item in the form designer.