Create repeating section in PowerApps (Canvas App) and save data in the SharePoint list
Hello readers,
Welcome to the new article, from our "PowerApps" training series - Today, we will learn how to create Repeating sections in PowerApps.
What is Repeating sections -
Repeating sections in PowerApps allows us to create dynamic forms or tables where users can add multiple rows of data.
Think of them as a way to handle repeating sets of information, like line items in an expense report or products in an order form
Whether we are building a complex data entry form, a dynamic survey, or an inventory tracking system, the ability to replicate sections dynamically can significantly enhance the user experience and streamline data collection.
This article will walk through the steps to achieve repeating sections in PowerApps, ensuring our applications are dynamic and user-friendly.
Technical requirements -
Before creating the PowerApp, we need a data source and also we need to ensure that our data source can handle repeating data.
Typically, this involves using a relational data model where a primary table is linked to a secondary table via a foreign key.
E.g., we might have an "Orders" table (primary) and an "OrderItems" table (secondary) linked by an "OrderID".
Step 1 - Setting up our Data Source
For this lab session, we will create a new SharePoint list named “Orders.” This list should have columns corresponding to the data you want to capture and will be treated as our primary list for storing order-related details.
Also, we will create a secondary list named "OrderDetails" to store the Items under each order and treat it as a child list for Parent-Child relations.
Step 2 - Designing our PowerApp screen (User Interface)
Open PowerApps Studio and create a new canvas app from scratch or use the existing app and add a new screen.
Let's dive into creating repeating sections using the form control -
Recommended by LinkedIn
Filter(OrderItems, OrderID = ThisItem.OrderID)
Step 3 - Performing CRUD operations in the form
To enable our users to add new items to the repeating section, we need to provide a mechanism for adding new rows dynamically.
Add new items
Collect(colOrderItems, {OrderID: ThisItem.OrderID, ItemName: "", Quantity: 0, Price: 0})
Filter(OrderItems, OrderID = ThisItem.OrderID) & colOrderItems.
Edit and Save Items
Now we need to allow users to edit and save items within the repeating section.
ForAll(colOrderItems,
Patch
(
OrderItems, Defaults(OrderItems),
{OrderID: OrderID, ItemName: ItemName, Quantity: Quantity, Price: Price}
));
Clear(colOrderItems);
Delete Items
Now it's time to implement functionality to delete items from the repeating section.
Remove(colOrderItems, ThisItem)
Step 4 - Adding validations & testing
Conclusion
Implementing repeating sections in PowerApps enhances the flexibility and functionality of your applications, making them more dynamic and user-centric.
Following the above steps, we can create powerful forms that accommodate varying data entries, thus improving user experience and data management.
Stay tuned for upcoming articles on PowerApps, where we will explore their functionalities in various scenarios.
References