Items property

App.Items — { ? }

The items of the app as an array, including all form groups, fields, buttons, text boxes and named values.

Accessing all items of the app through this property has many uses:

The following sections detail how these scenarios can be realized. Skip to the examples at the bottom for the concise version.

Making the background color red if a field is invalid

The BackgroundColor property determines the background color of a screen and all screens that follow that have no explicit background color set. That means that if the background color is set for the first screen of an app, and no other screens have a background color set, the first screen determines the background color of the entire app.

We can make use of this knowledge to make the background of the entire app red, but only if at least one field of the app is invalid. This formula is associated with the BackgroundColor property of the first screen:

IF(OR(NOT(App.Items.Valid)), Color.Red)IF(OR(NOT(App,Items,Valid)); Color,Red)

The formula fragment App.Items.ValidApp,Items,Valid returns a logical array, where TRUE indicates that the corresponding item is valid and FALSE indicates that the corresponding item is invalid. Applying the NOT function to this array negates every element, meaning that TRUE indicates that an item is invalid and FALSE indicates that an item is valid. (The ! operator would have had the same effect.)

Then, the OR function is applied to this array. It returns FALSE only if all elements of the array are FALSE. In other words, it returns TRUE if one or several elements are TRUE, meaning that it returns TRUE if one or several items are invalid.

Finally, the IF function is used to return the color red if one or several items are invalid. Otherwise, IF returns a blank value, which has no effect on the background color. The net effect is that the background color of the app is made red if one or several items of the app are invalid.

Enabling a button only if all fields have been filled out

The Enabled property of a button determines if users can interact with the button. If a button should only be enabled if all fields of the app have been filled out, associate this formula with the Enabled property of the button:

AND(ISDEFINED(App.Items.Value))AND(ISDEFINED(App,Items,Value))

The ISDEFINED function returns a logical array when its sole parameter is an array. TRUE elements in the array indicate that the fields have defined values, that is, have been filled out. Conversely, FALSE elements indicate that the fields have not been filled out.

Finally, the AND function returns TRUE only if all elements of the array are TRUE, otherwise it returns FALSE. The net effect is that AND returns TRUE only if all fields of the app have been filled out, prompting the Enabled property to only allow users to press the button once all fields have defined values.

Including all values of the app in an email

The Body property of email report buttons allows the body of an email to be set through a formula. While email report buttons have built-in support for including field values, through the IncludedFields property, building a text string manually to include in the email body allows us more flexibility.

Consider this formula, which should be associated with the Body property of an email report button:

TEXTJOIN(NEWLINE(), FALSE, App.Items.Label & ": " & App.Items.Value)TEXTJOIN(NEWLINE(); FALSE; App,Items,Label & ": " & App,Items,Value)

Above, the formula fragment App.Items.LabelApp,Items,Label returns a text array, made up of the labels of the items of the app. The formula fragment App.Items.ValueApp,Items,Value also returns an array, this time made up of the values of the items. Using &, the labels are joined together with the values, separated by a colon.

The resulting text array, where every element consists of a label, followed by a colon and a value, is converted into a single text string using the TEXTJOIN function. Its first parameter, NEWLINE()NEWLINE(), ensures that the array elements are separated from one another using line breaks.

Ranges versus this property

If the app only consists of the fields Field1, Field2 and Field3, these formulas are equivalent:

App.ItemsApp,Items
Field1:Field3Field1:Field3
{ Field1, Field2, Field3 }{ Field1; Field2; Field3 }

The second formula uses a range to create an array consisting of Field1, Field3 and all items that appear between them, which in this case is only Field2.

The chief advantage of the Items property, compared to a range, is that there is no need to update formulas when additional items are added to the app. If Field4 were to be added to the app, the Field1:Field3Field1:Field3 range would have to be changed to Field1:Field4Field1:Field4 everywhere it is used.

By contrast, App.ItemsApp,Items automatically includes Field4, and any other items that are added.

Filtering items

If you want to process only a subset of the items returned from this property, use the FILTER function. It can base its decision on which items to return on the property values of the items.

This formula only returns visible items:

FILTER(App.Items, App.Items.Visible)FILTER(App,Items; App,Items,Visible)

Crucially, you can also filter on the names of the items, using standard text functions. This formula only returns items whose names include the text string "Required":

FILTER(App.Items, CONTAINS(App.Items.Name, "Required"))FILTER(App,Items; CONTAINS(App,Items,Name; "Required"))

If you use a deliberate naming strategy for your items, you can use FILTER in conjunction with this property to ensure that you only process a specific subset of items.

Related properties

Use the Items property of a form screen to access all items of said form screen and the Items property of a form group to access all items of said form group.

There are many other properties that return only certain items. For instance, Fields returns all fields of the app, whereas NumberFields only returns the number fields of the app.

Examples

AND(App.Items.Valid)AND(App,Items,Valid)

Returns TRUE if all fields of the app are valid and FALSE otherwise. App.Items.ValidApp,Items,Valid returns a logical array, where each element reflects whether its corresponding item is valid. Finally, the AND function returns TRUE if all elements are TRUE and FALSE otherwise.

TEXTJOIN(NEWLINE(), FALSE, App.Items.Value)TEXTJOIN(NEWLINE(); FALSE; App,Items,Value)

Returns all field values of the app as a text string, where values are separated from one another using line breaks. The formula fragment App.Items.ValueApp,Items,Value returns an array of values, which the TEXTJOIN function joins together with line breaks.

AND(ISDEFINED(App.Items))AND(ISDEFINED(App,Items))

Returns TRUE if all fields of the app have been filled out. When the ISDEFINED function is applied to an array of items, it returns a logical array whose elements indicate if the corresponding item has a defined value. The AND function returns TRUE if all array elements are TRUE and FALSE otherwise.