web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PCF - On... handler pr...
Power Apps
Answered

PCF - On... handler property

(0) ShareShare
ReportReport
Posted on by 68

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?

  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    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/493217

     

    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,

  • TechnoKitty Profile Picture
    68 on at

    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?

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    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 Profile Picture
    1,400 on at

    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 Profile Picture
    68 on at

    @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) 

  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    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,

  • TechnoKitty Profile Picture
    68 on at

    This worked perfectly, thanks again!

  • AlexChenCvz Profile Picture
    2 on at

    Thanks @v-yutliu-msft, that's great to hear the the OnSelect event would be added to the PCF component, but can we assume you will also add the support for the Select on the PCF component at the same time?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard