cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TechnoKitty
Level: Powered On

PCF - On... handler property

Hi there!

I'm building a component that processes some data and should fire "OnSuccess" and "OnError" events as an outcome. This can be used then in a Power App to present the results accordingly. Think like "OnSelect" standard button property or "OnTimerEnd" etc. 

So, I'm looking for a way how to define such a property and cannot find this in the documentation. How might I accomplish that?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: PCF - On... handler property

Hi @TechnoKitty ,

I totally agree with @ben-thompson  and @DianaBirkelbach .

In PCF, it's not supported to create custom behavior properties like "OnSuccess" and "OnError" currently.

For now, you could just  register the OnChange event.

But you could use output property and set it to some value when the event happens, which should work as "OnSuccess" and "OnError".

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Community Support Team
Community Support Team

Re: PCF - On... handler property

Hi @TechnoKitty ,

Do you want to use behavior properties like "onselect" in component?

I'm afraid there's only one behavior property "OnReset" supported in component.

You could follow this doc to know how to use this behavior property in many ways:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/component-behavior

What's more, you could also consider use a Toggle's OnChange to achieve the feathers that you want.

Here's a similar issue for your reference:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Navigation-from-Dialog-Components/td-p/49321...

 

I'm very glad to find that this feather has been started to developed, hoping to see it soon!

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Actions-on-Components/idi-p/238399

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
TechnoKitty
Level: Powered On

Re: PCF - On... handler property

Thank you, @v-yutliu-msft - I voted for the idea!

Just want to clarify, my question was about code components, not the "custom component" that is created in Power App Studio. Does it change your answer anyhow?

Re: PCF - On... handler property

In PCF you cannot define custom events.

I'm not a pro in CanvasApps, but since for PCFs you can only register the OnChange event, maybe you can work with special values in your PCF, that you evaluate in CanvasApp to decide if you treat it as a "OnSelect" or "OnTimerEnd" event.

So you set the PCF property value to the string "OnSelect" or to the string "OnTimerEnd", and the CanvasApp register to OnChange event of your PCF and decide which event was actually meant. 

PCF Controls of type boolean might work too(so you only check if it's true=OnSelect, false=OnTimerEnd)...

But this is only an idea,  I've never tried out if this works...

ben-thompson
Level 8

Re: PCF - On... handler property

I'm confused by why you are using a PCF component to manipulate data - as unless user interaction is required that really should be a server level task .

 

A PCF component is really a user interface component, you pass parameters into it and the control then renders the information in the way you want it to work.  PCF components are also built on a framework with defined interfaces / events that are the only things the canvas / CDS form expects to interact with so you cannot add your own events as they would be ignored (webresources are still supported for exactly that reason).

 

That doesn't mean that you can't do most of what you want. 

 

For onSuccess calling notifyOutputChanged within your code will tell the form that the data is valid and will trigger the form calling getOutputs to receive the newly updated values of the parameters the control is bound to (note, I believe canvas components work slightly differently).

 

Error handling and errors however need to handled within the control itself. 

 

Finally don't forget you can bind an attribute to multiple controls - we do this on all our admin pages that used to need 100s of lines of Javascript but now consist of zero code and multiple PCF components - where one control (selectEntity) acts as the master control / trigger for various select attribute / select view / select lookup controls underneath. 

 

 

 

 

TechnoKitty
Level: Powered On

Re: PCF - On... handler property

@ben-thompson 

This is a Canvas app component. It does some front end logic and manipulate data using fetch() request to an external server. When it's done, the other app logic needs to happen - e.g. Navigate to the next screen.

Your and @DianaBirkelbach thoughts helped me to understand that I can use output property and set it to some value (e.g. "Processed") when the event happens. This would solve the problem in a way that other components can read it (e.g. I can define a button with property Enabled set to MyComponent.Result = "Processed"), but it doesn't help to do an action automatically (e.g. Navigate).

So, missing really the "On..." events in the frameworks (for Canvas app components) 

Community Support Team
Community Support Team

Re: PCF - On... handler property

Hi @TechnoKitty ,

I totally agree with @ben-thompson  and @DianaBirkelbach .

In PCF, it's not supported to create custom behavior properties like "OnSuccess" and "OnError" currently.

For now, you could just  register the OnChange event.

But you could use output property and set it to some value when the event happens, which should work as "OnSuccess" and "OnError".

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

TechnoKitty
Level: Powered On

Re: PCF - On... handler property

This worked perfectly, thanks again!

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Users online (9,637)