Skip to content

Latest commit

 

History

History
76 lines (51 loc) · 4.34 KB

component-behavior.md

File metadata and controls

76 lines (51 loc) · 4.34 KB
title description author ms.subservice ms.topic ms.date ms.author ms.reviewer search.audienceType contributors
Behavior formulas for components (experimental)
Do one or more tasks in canvas app when a component-based action occurs.
jorisdg
canvas-developer
article
06/01/2022
jorisde
mkaur
maker
jorisdg
mduelae

Behavior formulas for components (experimental)

[This article is pre-release documentation and is subject to change.]

Important

This is an experimental feature. For more information, see Experimental and preview features.

Specify one or more behavior formulas that run when an event triggers a change in component instances.

For example, set a component's OnReset property to one or more formulas that do initialization and clear input. Reset values when the Reset function runs on the component instances.

Note

The feature to create custom behavioral properties is currently experimental. However, you can use the default OnReset property that is available on all components in your production environment.

OnReset

With a component master selected, select OnReset in the drop-down list of properties (on the left side of the formula bar), and then enter one or more formulas.

[!div class="mx-imgBorder"] OnReset property.

To test OnReset, configure a control to reset the component. For example, set the OnSelect property of a button to this formula: Reset(ComponentName).

Example - Reset timer

[!div class="mx-imgBorder"] OnReset Example - Reset timer.

In this time picker component, two variables are used to display the time _selectedHour and _selectedMinute. When the picker gets reset, these variables should be reset to a default value, say 12: 12.  The OnReset property for the component has the following formula: Set(_selectedHour,12); Set(_selectedMinute,12)

To trigger reset, go to a screen and insert an instance of the component. Add a button and configure OnSelect of the button to call Reset(TimerComponent_instance) to trigger OnReset.

[!div class="mx-imgBorder"] Reset button.

Update OnReset using custom property

Besides resetting a component instance from outside of the component, there's another method to trigger the OnReset from the inside. "Raise OnReset when value changes" is an option when creating a custom input property. It allows the value changes of this property to trigger OnReset of the component. This method is designed to set and reset the default value easily.

OnReset using custom property.

Example

[!div class="mx-imgBorder"] OnSelect example animation.

The example above shows reviewing order numbers and updating the numbers. The numeric up and down component is used to increase or decrease number of orders. When selecting the gallery on the left, the default number of the numeric up and down component is reset to display the order number of the selected tool. Raise OnReset when value changes made it possible to reset the default value when the input changes.

To do so, check Raise OnReset when value changes of the default input property. OnReset of the component is set to Set(_numericValue,'Numeric up down'.DefaultValue). _numericValue is the variable to store the value of the current order value. Set the Default of the text input control to If(IsBlank(_numericValue), 'Numeric up down'.DefaultValue, _numericValue).

See also

[!INCLUDEfooter-include]