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 / PowerApps Component Fr...
Power Apps
Unanswered

PowerApps Component Framework

(0) ShareShare
ReportReport
Posted on by 18

Hi Folks,

 

Quick question regarding PowerApps Component Framework. Is there a way to prevent save a parent form if there is any error occurred in PCF? 

 

The scenario I have is, my custom control generates random string as encryption key based on the input length provided in the configuration input. Since, its a key, space characters are not allowed hence, my control throws an error. However, that error is part of PCF life cycle and not been reported back to the form execution. Hence, the form is still allowed to save unless I inject a JS on form events. 

 

Any help is appreciated. 

 

Cheers

Jai

I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @jhashwani ,

    Do you want to prevent the custom PCF control from saving when there is an error occurred?

     

    If you want to prevent the custom PCF control from saving when there is an error occurred, I afraid that there is no way to achieve your needs in PowerApps currently.

     

    Currently, within PowerApps Component Framework, there is no function/context execution object to receive the error occurred within the PCF control.

     

    If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

    https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

     

    As an alternative solution, you could consider defined a JavaScript in your PCF code, then use the JS Code to validate if the entered characters are valid, if not, alert a error message.

     

    Best regards,

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

    Hi @jhashwani , 

     

    Unfortunately you cannot control the form from inside the PCF, but maybe you can make use of required property of a field.

    I'm thinking about setting the PCF field (where the PCF is registered) on the form as "Required", and inside your PCF - in getOutputs() - return  empty string as a value for your  parameter (as long the key is not valid). 

    If the required field are not  filled in, the form should automatically stop the saving.

     

    In case your attribute should be filled in only in some cases, and you cannot set it on required, you could work with a second bound parameter for your PCF, designed only for this purpose (a "valid" attribute, that's also required on the form).

     

    I haven't tested this out, but maybe this can be an approach you can start with.

     

    Best regards,

    Diana

  • Ben Thompson Profile Picture
    1,400 on at

    As Diana says the only way to handle it at the moment is to use a required field and return an empty value unless until you have the information you want.

     

    I created an idea to solve this issue a year ago and it's still under review so if you want it fixed vote for it https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Allow-a-PCF-field-component-to-flag-a-field-as-invalid-and-stop/idi-p/293890

  • Ben Thompson Profile Picture
    1,400 on at

    There is another solution as Benedick Bergmann blogged about earlier today which uses a two option field to check for validation

     

     https://benediktbergmann.eu/2020/05/01/pcf-prevent-saving-the-form-when-input-is-invalid/

     

    It's still not an ideal solution though but it may be neater than making the text field a required field.

  • jhashwani Profile Picture
    18 on at

    Thanks everyone for your input. Looking at the current limitation In PCF, the best way to handle errors is using form JavaScript which is what I end up doing. 

    One elegant way I found is, an

    error can be thrown by the PCF on UI perhaps, we can prevent save form on save event and avoid any Control error notification for better usability. 

    tough, having form execution context and notification access for a PCF field would be nice to have. That way, a solution would be intact at one place Instead of two.

     

    cheers 

    Jai

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

    Hi @jhashwani ,

    I agree with your though almost. Currently, as an available solution, I think JavaScript code could achieve your needs. You could set up JavaScript logic to validate the entered character.

     

    If you want to display the error message within your PCF control, I think the openErrorDialog function under form context could achieve your needs:

    context.navigation.openErrorDialog(options)

    Please check the following article:

    https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/navigation/openerrordialog

     

    Best regards, 

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

    Hi @jhashwani ,

    Making a required boolean bound to your pcf works. I've tried it out. https://dianabirkelbach.wordpress.com/2020/05/15/can-pcfs-communicate/.

    And here the github with the tests: https://github.com/brasov2de/EvaluatePCFRequiredField

    I've implemented that in a more generic way, but you don't necessarily need the postMessage, you can just define in the manifest another property linked to a required boolean attribute, which stops the form saving.

    Best regards,

    Diana

  • Ben Thompson Profile Picture
    1,400 on at

    @DianaBirkelbach (sorry about this I'm actually replying to 2 of your comments at the moment with slight corrections and I feel guilty).

     

    I've implemented that in a more generic way, but you don't necessarily need the postMessage, you can just define in the manifest another property linked to a boolean attribute (that is set on the form to be required) which stops the form saving.

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

    Don't worry @ben-thompson , 

    Since my answer wasn't clear explained, your reply will help the others understand what I mean. Thank you for that.

    I'm grateful being able to exchange ideas with you guys. To the other thread I'll come back soon. 🙂

    Best regards,

    Diana

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 529 Most Valuable Professional

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard