Over time, we have introduced more and more features aimed at making apps more dynamic. By dynamic, we mean the ability for apps to change their appearance and behavior based on data entered by your users. We added calculated properties early last year, making it possible to use formulas to determine things like the recipients of reports and whether a field or a button should be visible or grayed out .
We’re now taking the next logical step and enabling formulas to be used to
determine labels, validation messages and field units. Let’s say that you have a
drop-down field that enables users to choose between metric and imperial units.
You can associate a formula with the TrailingUnit property of all weight
fields that selects the unit “kg” if metric units have been selected and “lbs”
IF(UnitSelector = "Metric", " kg", " lbs").
Validation messages appear when fields fail validation. Let’s say
that you associate the following formula with the Valid property of a field
(Tonnage = DefaultTonnage) || (Tonnage < MaximumTonnage),
where there is a field named MaximumTonnage determining the maximum value for
the Tonnage field and another field named DefaultTonnage specifying a
default value. Tonnage is valid if it is below that maximum value or equal to
the default value. What should the validation message say if the field fails
validation? With a formula-driven validation message, you can associate the
following formula with the ValidationMessage property of the Tonnage field:
"If not " & DefaultTonnage.FormattedValue & ", must be less than " &
MaximumTonnage.FormattedValue & "."
Use the Label property of groups, fields, buttons, panels and list panel
options to change their labels through formulas. Let’s say that you use a
stepper to enable your users to add and remove fields, a technique
we demonstrated in January, and that the field with the
stepper is named NumberOfVisibleFields. Further, assume that there is a button
below the fields that sends a report with their values. To
make the button label indicate the number of records that are sent, associate
the following formula with its Label property:
"Send " &
NumberOfVisibleFields & " records."
Many calculated properties are exposed through the inspector, where you can press the faint fx button to edit their formulas. In an effort not to clutter the inspector with advanced and rarely-used properties, it does not contain all calculated properties. Before this release, the most notable example was the InitialValue property, allowing you to set initial field values through formulas. You won’t find the Label, ValidationMessage, LeadingUnit and TrailingUnit properties in the inspector, either. Rather, you must use the property selector to edit their formulas:
We have written a new sample app that uses the Label property to enable the user to name fields. Check it out!