Pragmatic Works Nerd News

Level Up Your Canvas Power Apps with Collections!

Written by Matt Peterson | Nov 13, 2024

In this video, Matthew Peterson from Pragmatic Works demonstrates how to effectively use collections in Canvas Power Apps to manage and display data across different screens. Collections are used to temporarily store and manipulate data in an app, and Matthew provides step-by-step guidance on how to use them for scenarios like selecting multiple records and displaying detailed information on another screen.

 

What Are Collections in Canvas Power Apps?

Collections are used to store and manipulate data temporarily within a Power App. They are particularly useful for gathering data from multiple records, making them available across screens, and allowing users to interact with the data in real time.

Use Case: Multi-Select and Display Records

In this demonstration, Matthew uses an example where users select multiple records from a gallery and view the selected details on another screen. He explains how collections make it easier to pass this data between screens and ensure users see the correct information based on their selections.

Step-by-Step Guide to Creating a Collection

  1. Create a gallery with data that users can interact with (e.g., patient data).
  2. Add a checkbox to each gallery item to allow users to select multiple records.
  3. Use the "OnCheck" property of the checkbox to add selected records to the collection using the Collect function.
  4. Use the "OnUncheck" property to remove records from the collection with the Remove function.
  5. Create a second screen where the collection is displayed, such as in a gallery, to show details of the selected records.

Clearing the Collection

To enhance the user experience, Matthew shows how to clear the collection when users navigate back to the selection screen. This ensures that when users return to the gallery, no checkboxes are selected, preventing confusion.

Dynamic Checkboxes

Matthew also demonstrates how to make checkboxes dynamic by using a formula in the Default property that checks if a record is in the collection. This ensures the checkbox reflects the state of the collection, showing a check mark only when the record is part of the collection.

Conclusion

Collections provide a powerful way to manage data in Canvas Power Apps, allowing developers to store, manipulate, and display data across multiple screens. Matthew's demonstration offers a practical example of how to implement collections for selecting and viewing multiple records, making this a valuable tool for Power Apps developers. 

Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Apps and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.