A
C
D
I
R
S
T
What is the ThisItem Function?
The ThisItem function in Power Fx allows you to retrieve the properties of the current item in a gallery or form. For example, if you have a gallery that displays a list of items, you can use the ThisItem function to retrieve the properties of the currently selected item.
How to Use the ThisItem Function
To use the ThisItem function, you need to first create a gallery or form that displays a list of items. Once you have your gallery or form set up, you can use the ThisItem function to access the properties of the current item.
Here’s an example of how to use the ThisItem function in a gallery:
Gallery1.Items
This formula returns a table of all the items in the gallery. To access the properties of the current item, you can use the ThisItem function like this:
Gallery1.Selected
This formula returns a record of the currently selected item. You can then use dot notation to access the properties of the record. For example, if your records have a field called "Title", you can access it like this:
Gallery1.Selected.Title
This formula returns the value of the "Title" field for the currently selected item.
Why Use the ThisItem Function?
The ThisItem function is useful because it allows you to create dynamic Power Apps that respond to user input. For example, you can use the ThisItem function to create a form that lets users edit the properties of a selected item.
Here's an example of how to create an edit form using the ThisItem function:
1. Create a gallery that displays a list of items.
2. Add a button to the gallery that opens a form for editing the selected item.
3. In the form, add text input controls for each property you want to edit.
4. Set the Default property of each text input control to the corresponding property of the selected item using the ThisItem function.
Here's what the formula for the Default property might look like:
If(IsBlank(ThisItem.Title), Parent.Default, ThisItem.Title)
This formula checks if the "Title" field of the selected item is blank. If it is, it sets the default value of the text input control to the default value of the parent form. Otherwise, it sets the default value to the value of the "Title" field of the selected item.
The ThisItem function in Power Fx is a powerful tool for creating dynamic Power Apps that respond to user input. By mastering this function, you can create custom apps that are tailored to your specific needs. We hope this guide has been helpful in showing you how to use the ThisItem function in your own Power Apps.