Behavior Properties in Canvas Power App

By | June 10, 2021

Canvas App is no code/low code business app with which you can design the app by dragging and dropping elements onto a canvas. Canvas app is used to build mobile apps with various functionalities. Recently, we had a client requirement and to fulfill this requirement we needed to create multiple screens where some of the screen had common control. So, we have decided to create a component of the Power App. On one of the screens, we had the functionality to schedule an appointment with the customer. Though we used component but now we have a requirement to show a message when the sales rep selects the appointment date. To achieve this task, we wanted to add some code when component control changes. Previously, there was no way to do something when control value changes but with the recent release, it is available in Power App as behavior properties. But it is still in the experimental section. To use the behavior properties feature we need to enable it first.

To enable please follow the steps given below:

  • First, click on File in Canvas App.
  • Then go to Settings >Upcoming features.
  • Then go to Enhanced component properties and enable it.

Behavior properties in Canvas Power App

Once you enable the “Enhanced component properties”, we will be able to see the Behavior property when we add new custom property from the customer properties section as shown below:

Behavior Properties in Canvas Power App

As to achieve our requirement to show message to sale rep when they select appointment date to reconfirm appointment date; we have added a custom property with name changeDate of type as Behavior.

To send the selected appointment date, we added parameter to behavior custom property.

Behavior properties in Canvas app

After clicking on New parameter, the below window opened where we mentioned name and data type.

Behavior properties in Canvas app

Next, select the date control from a component that we created and pass custom behavior property with parameter in onChange event to appointment date control.

Behavior properties in Canvas app

Finally when we select the component, we will see the “changeDate” along with “OnReset” event. To show the message then select “changeDate” and define notify function as shown below:

Behavior properties in Canvas app

When the sales rep opens the Canvas App and tries to book an appointment and select the appointment date then the message will be shown that you have selected an appointment date. For example “06/21/2021”.

Behavior properties in Canvas app

Conclusion:

With help of Behavior property, we can create custom properties to achieve more functionalities.

Reference Source – https://powerapps.microsoft.com/es-es/blog/enhanced-component-properties/