Special properties

Completed

Forms have a couple of overlooked properties and named operators. This section covers when and how to use the Error property, Unsaved property, ThisItem named operator, and Parent named operator.

Error property

The Error property contains the output of any error messages that are generated by the Form control. To view the contents of the property, add a Text label control to the screen and then for the Text property enter the formula Form1.Error. It's blank if there's no error, but if you try to submit a form without entering all of the required columns you would see a message such as "An entry is required or has an invalid value. Correct and try again." You can use this value in formulas or other controls to design your apps error handling.

Unsaved property

The Unsaved property is a Boolean property that is true when a form has been edited but not submitted. You can use this property to check to see if the user has unsaved change. An example of this would be to set up the back button on your app to check to see if the form was unsaved, if there's unsaved data then don't navigate. You could use the following formula in the OnSelect property of a Button control to achieve this.

If(YourFormName.Unsaved = false, Navigate(WelcomeScreen, ScreenTransition.Cover))

This function would check to see if the Form control named YourFormName had false for the Unsaved property. If the property is false, then it would navigate the user to the screen named WelcomeScreen. If the property is true, then nothing would happen. In your app, you could expand upon this concept to add a warning message or even a popup box telling the user why they couldn't navigate away.

In addition to these properties, the Form control includes the named operators, ThisItem and Parent, like the Gallery control.

ThisItem named operator

Within your Form or Gallery control, you can reference the values of the current record by using ThisItem. This is helpful when you're manually creating formulas to reference values from the record. For example, if you wanted to add a label that combined the FirstName and LastName columns into one string with a space in the middle, you could use the following formula.

ThisItem.FirstName & " " & ThisItem.LastName

This formula assumes that you have a column named FirstName and a column named LastName for the record you're displaying in the Form control.

Parent named operator

Within the Form and Gallery controls, there's the concept of a parent object. In the case of an Input or other control in a Form control, you can pull a property from the data card by using Parent. and the name of the property that you would like to reference. An example is the default value. Data cards store this value in their Default property. From an Input control, you can reference that value with the formula Parent.Default in the Default value of the Input control. Galleries have the same Parent concept for querying properties from the Gallery control in the controls within the gallery.