Creating a Repeating Table in Power Apps Using Gallery and Collection

Loading

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

  1. Open Power Apps Studio.
  2. In the OnStart property of the app, initialize an empty collection:
ClearCollect(colEmployees, [])
  1. 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.

  1. Insert a Gallery (Vertical Layout) into your screen.
  2. Set the Items property of the Gallery to:
colEmployees
  1. 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)

5. Adding a Row to the Collection

  1. Insert a Button below the Gallery with the text “Add New Row”.
  2. 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:

  1. Set the OnChange property of TextInput_EmployeeName:
Patch(colEmployees, ThisItem, {Title: TextInput_EmployeeName.Text})
  1. Set the OnChange property of TextInput_Age:
Patch(colEmployees, ThisItem, {Age: Value(TextInput_Age.Text)})
  1. Set the OnChange property of TextInput_Department:
Patch(colEmployees, ThisItem, {Department: TextInput_Department.Text})

7. Deleting a Row from the Collection

  1. Add a Delete Button inside the Gallery.
  2. Set its OnSelect property:
Remove(colEmployees, ThisItem)

8. Submitting Data to SharePoint List

  1. Insert a Submit Button below the Gallery.
  2. 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

  1. Run the app and add test data.
  2. Click the Submit button and verify records in SharePoint.
  3. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *