Skip to main content

Powerapps: Collections in Canvas Apps | Collect, ClearCollect, Clear in Powerapps

Collections: Collections are special types of variables or data storage mechanism which can be used to manipulate the data within Power Apps. 

Collections are usually a group of similar items which acts like a table of values with columns and rows. 

We can create, update, delete, use it as the data source for a gallery to view the items within Power App. 


Collect, Clear, and ClearCollect functions: 

Collect: In Power Apps, the Collect function is used to create or update a collection in your app. 

Collections are temporary data sources that allow you to store and work with data within your app. 

The Collect function is versatile and can be used in various scenarios to add, modify, or remove records from a collection. 

Syntax: Collect( IceCream, { Flavor: "Pistachio", Quantity: 40 }, { Flavor: "Orange", Quantity: 200 } ) 

Adds two records to the IceCream collection that includes a quantity of pistachio and orange ice cream. 

Clear: In Power Apps, the Clear function is used to remove all records from a collection, reset the contents of a control, or clear the input from an input field. Its primary purpose is to clear data or reset the state of elements within your app. 

Syntax: Clear( IceCream ) 

Removes all records from the IceCream collection. 


ClearCollect: The ClearCollect function deletes all the records from a collection. And then adds a different set of records to the same collection. With a single function, ClearCollect offers the combination of Clear and then Collect. 

Syntax: ClearCollect( IceCream, { Flavor: "Strawberry", Quantity: 300 } ) 

Clears all data from the IceCream collection and then adds a record that includes a quantity of strawberry ice cream. 



Launch: Launches a webpage or a canvas app. 

 Syntax: Launch( " https://www.google.com/" ) 

Navigate: In Power Apps, the Navigate function is used to navigate between screens within an app. It allows you to programmatically control the flow of the user interface by directing users to different screens based on specific conditions or events. 


Syntax: Navigate( Screen [, Transition [, UpdateContextRecord ] ] ) 

 Screen - Required. The screen to display. In place of Screen, you can also use a control that is on the screen you wish to navigate to. 

 Transition - Optional. The visual transition to use between the current screen and the next screen. See the list of valid values for this argument earlier in this article. The default value is None. 

 UpdateContextRecord - Optional. A record that contains the name of at least one column and a value for each column. This record updates the context variables of the new screen as if passed to the UpdateContext function. 


Back: In Power Apps, the Back function is used to navigate back to the previous screen in the app. 

Syntax: Back( [ Transition ] ) 


Transition - Optional. The visual transition to use between the current screen and the previous screen. Refer to the list of valid values for this argument earlier in this article. By default, the transition through which a screen returns is the inverse of the transition through which it appeared. 


Have a great time using these functions in powerapps.!


Please support by following me on my LinkedIn profile:

Pavan Kumar Vuyyuru

Comments

Popular posts from this blog

Understanding the Basics of C# Plugins in Dynamics 365: A Simple Account Update Example

Welcome to my blog! Today, we’ll dive into the world of C# plugins in Dynamics 365. If you're working with Dynamics 365, you’ve likely heard of plugins, which allow you to extend the platform's functionality and automate various processes. In this post, I’ll walk you through the parts of a plugin, using a simple example of updating an account record. What Is a C# Plugin? A plugin in Dynamics 365 is a custom business logic component that responds to specific events in the system. Plugins are executed in response to a trigger event, like creating or updating a record, and can be used to modify data or integrate with other systems. Written in C#, they are powerful tools for customizing and extending the functionality of Dynamics 365. The Structure of a C# Plugin A plugin typically consists of several parts: Plugin Registration – You register the plugin in Dynamics 365 to define what event triggers the plugin (create, update, delete) and which entity it will affect (e.g., A...

Essential Dynamics 365 Plugins for Sales & Customer Service

Introduction In Dynamics 365, plugins automate business processes, enforce rules, and ensure data integrity. Whether in Sales or Customer Service , plugins help streamline workflows by executing logic at the right time in the pipeline. This post covers key plugin scenarios , detailing: ✅ Execution pipeline stage (Pre-Validation, Pre-Operation, Post-Operation) ✅ Synchronous or Asynchronous execution ✅ Pre-Image / Post-Image usage ✅ Rollback handling Rollback Handling in Plugins When Does a Plugin Rollback? A plugin automatically rolls back if: An exception is thrown in a synchronous plugin. A transaction fails in a Pre-Validation or Pre-Operation stage. How to Handle Rollbacks? Use Try-Catch Blocks : Prevent unwanted failures by catching errors and logging details. Throw an Exception When Needed : Stop invalid data changes (e.g., prevent closing an Opportunity without a Quote). Compensating Logic in Async Plugins : Since Post-Operation Async plugins do not par...