Valid property
Special value available in formulas:
Item
The field this property is part of, enabling multiple checked items in the app designer to share the same formula and be updated all at once.
Consider the fields Field1 and Field2, which should
only be considered to be valid if their values are
greater than 4. Without using the Item
value, the Valid
property of Field1 would need to use the formula Field1 > 4Field1 > 4 and the Valid
property of Field2 would need to use the formula Field2 > 4Field2 > 4.
Using Item
, both formulas can read Item > 4Item > 4. This is useful
if you have many fields and you want to be able to update their
formulas all at once. To do so, click their check boxes in Calcapp
Creator and make sure that a checked field is selected. Then, when you
update a formula for one checked field, you update all the other
checked fields too, which is a great timesaver.
Use Item
in exactly the same way you'd use the regular
name. Field1.VisibleField1,Visible and Item.VisibleItem,Visible are equivalent, for
instance.
Whether the field is valid. The value of an invalid field is shown in red (unless a different warning color has been set). Below the field, a validation message is shown. Customize it through the ValidationMessage property.
To make a field required, use this property in conjunction with the NextScreenAvailable property of screens (preventing users from moving on to the next screen) and the Enabled property of buttons (preventing users from pressing a button). See below for more information.
Writing formulas determining if a field is valid
To determine if a field is valid, you must write a formula and associate it with this property. This formula must return TRUE if the field is valid and FALSE otherwise.
This formula only considers a switch field to be valid if the value of NumberField1 is greater than 3 and the value of SwitchField1 is FALSE:
(&& should be read as "and." ! should be read as "not.")
Determining if a field is valid from a formula
On its own, the Valid property only shows a validation message and displays the field value in a different color if the field fails validation. Users are not prevented from moving on to a different screen or from pressing buttons, nor are any calculations inhibited.
Enable these features by accessing whether a field is valid from other formulas. For example, associate the following formula with the Value property of Field2 to prevent it from calculating a value unless Field1 is valid:
If blank values are considered valid (which we recommend), you also need to use ISDEFINED to make sure that a value has been entered:
(&& should be read as "and.")
To prevent a user from moving to the next screen, unless both Field1 and Field2 are valid and have defined values, associate a formula like the following with the NextScreenAvailable property of a form screen:
To prevent a user from pressing a button unless all fields of the Field1:Field5Field1:Field5 range are valid and have defined values, associate a formula like the following with the Enabled property of a button:
The Field1:Field5Field1:Field5 range includes Field1 and Field5, as well as all fields appearing between them. (Field1:Field5).Valid(Field1:Field5),Valid returns a logical array like { TRUE, FALSE, TRUE, TRUE, FALSE }{ TRUE; FALSE; TRUE; TRUE; FALSE }, where each individual element indicates whether the corresponding field is valid.
ISDEFINED(Field1:Field5)ISDEFINED(Field1:Field5) also returns a logical array, where each individual element indicates whether the corresponding field value is defined (not blank). When && is applied to two arrays, a single logical array is returned, where each individual element is only TRUE if the elements at the same position in the two arrays are both TRUE. The net effect is that an array is returned, where each individual element indicates whether the corresponding field is both valid and has a defined value.
Finally, AND is applied to the resulting array and only returns TRUE if all elements of it are TRUE. The end result is that the formula only returns TRUE if all fields of the Field1:Field5Field1:Field5 range have defined values and are valid.
Examples
Considers a switch field to be valid only if the value of NumberField1 is greater than 3 and the value of SwitchField1 is FALSE.
This formula is associated with the Value property of a number field. A value is only calculated if Field1 has a defined value and is valid. Otherwise, a blank value is produced.
This formula is associated with the NextScreenAvailable property of a screen. The user is only permitted to proceed to the next screen if Field1 and Field2 both have defined values and are considered valid.
This formula is associated with the Enabled property of a button. The user is only permitted to press the button if all fields of the Field1:Field5Field1:Field5 range have defined values and are considered valid. The Field1:Field5Field1:Field5 range includes Field1, Field5 and all fields that appear between them.