1. Introduction
A repeating table in Power Apps allows users to dynamically add, edit, and delete rows of data before submitting them to a SharePoint list. This is useful in scenarios where users need to input multiple related records in a structured format. In this guide, we will create a repeating table using a Gallery and Collection, and store the data in a SharePoint List upon submission.
2. Setting Up the SharePoint List
Create a SharePoint list named EmployeeRecords with the following columns:
- Title (Single line of text) – Stores the Employee Name
- Age (Number) – Stores the Employee Age
- Department (Choice) – Stores the Employee Department
3. Creating the Collection in Power Apps
Collections store temporary data in Power Apps. We will create a collection to hold our repeating table data.
Initialize Collection on App Start
- Open Power Apps Studio.
- In the OnStart property of the app, initialize an empty collection:
ClearCollect(colEmployees, [])
- Run the OnStart action to initialize the collection.
4. Adding a Gallery for Repeating Table
A Gallery control is used to display and edit multiple rows dynamically.
- Insert a Gallery (Vertical Layout) into your screen.
- Set the Items property of the Gallery to:
colEmployees
- Insert Text Inputs inside the Gallery for user entry:
- Employee Name:
TextInput_EmployeeName
(Default: ThisItem.Title) - Age:
TextInput_Age
(Default: ThisItem.Age) - Department:
TextInput_Department
(Default: ThisItem.Department)
- Employee Name:
5. Adding a Row to the Collection
- Insert a Button below the Gallery with the text “Add New Row”.
- Set its OnSelect property:
Collect(colEmployees, {Title: "", Age: 0, Department: ""})
Each time this button is clicked, a new blank row will be added.
6. Editing the Collection Values
To update collection values dynamically:
- Set the OnChange property of
TextInput_EmployeeName
:
Patch(colEmployees, ThisItem, {Title: TextInput_EmployeeName.Text})
- Set the OnChange property of
TextInput_Age
:
Patch(colEmployees, ThisItem, {Age: Value(TextInput_Age.Text)})
- Set the OnChange property of
TextInput_Department
:
Patch(colEmployees, ThisItem, {Department: TextInput_Department.Text})
7. Deleting a Row from the Collection
- Add a Delete Button inside the Gallery.
- Set its OnSelect property:
Remove(colEmployees, ThisItem)
8. Submitting Data to SharePoint List
- Insert a Submit Button below the Gallery.
- Set its OnSelect property:
ForAll(colEmployees,
Patch(EmployeeRecords, Defaults(EmployeeRecords), {
Title: Title,
Age: Age,
Department: Department
})
);
Clear(colEmployees)
This loops through the collection and saves each row to SharePoint.
9. Testing and Best Practices
- Run the app and add test data.
- Click the Submit button and verify records in SharePoint.
- Implement validations to prevent empty submissions.
Conclusion
This guide provided a detailed approach to creating a repeating table using Gallery and Collections, and storing the data in a SharePoint List. By following these steps, you can build dynamic and interactive Power Apps forms that allow users to manage multiple records efficiently.