cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Customize Error Message for Datacard

I'm using a PowerApps form linked to a SharePoint list. I have made a few fields required, but whenever I test the validation by leaving them blank, the fields don't have error messages underneath them and error messages only populate the top banner of the canvas app. I noticed that the text property of the datacard error message is set to 'Parent.Error' and whenever I change this to a custom text, the text is visible even when there is no error. I also noticed that the visible property is set to ''Parent.DisplayMode=DisplayMode.Edit". No idea on how to change this. 

 

How can I make a custom error message only display when the error is thrown? 

1 ACCEPTED SOLUTION

Accepted Solutions

@JMAFO 

There are a couple of considerations you need to make in regard to error handling - the first is "when".  When do you want to deal with errors?  Before the form is submitted or after?  I would suggest to consider dealing with them prior to submit.  Don't even let a user submit a form unless there is a valid set of data to be submitted. 

The next is, how do you want to deal with that scenario?  Error messages, disabled controls, notifications, etc.

 

There are lots of different ways to go about it, but you have full control on how you want it to happen.

Let's take a scenario where you want to validate before submit and yet provide feedback enough to let the user know what they need to do.

 

First, it seems that Edit forms kind of know what they are when first created, but don't update themselves when the underlying datasource is changed.  So, if you create a form and then change fields to be required.  The form will not update to reflect that.  If you remove the fields from the form and add them back in they will then reflect the change (caveat - this will only happen after you get out of the design and back in - even a refresh of the data source while you're in it doesn't seem to update that properly)

SO - that will fix the issue of your forms not providing information about the required fields.  (This might be all you need at this point)

 

Next - the error messages are pretty generic.  You can change them as you have found...set the text as you need.  Now with that, you also need to set (with the Visible property) when that message is displayed.  By default, the Text of the message is set to the Error of the Parent.  This will be whatever the datasource returns as an error.  The visible is set whenever you're in edit mode.  On the label, you can 1) customize the text property and then 2) set the Visible property to (!IsBlank(Parent.Error) && Parent.DisplayMode=DisplayMode.Edit).  

At this point, you will have a custom error message and it will only appear when there is an error.  

It's still a little messy because, you will get this error then for any error that occurs and you'll also get the notification bar about it.

 

If you want to go the next step and get rid of the above mess...then consider disabling the submit button until the form is validated.  You can actually do it a couple ways.  One is to set a formula for the Disabled property of the button/icon.  The other way is to put in some logic to the formula of the button to 1) check for valid  2) if not valid, set a variable and done 3) if valid reset variable and submit the form. Then, with that variable, you can use it for the visible property of the error messages to "turn them on" so the user knows.

 

I realize that last concept paragraph if high-level concept.  I didn't go much deeper because we might have solved your issue at the first solution.  So, if this helps, I am hopeful.  If not, please post back and provide an area you are wanting more detail or having more problems.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

9 REPLIES 9

@JMAFO 

There are a couple of considerations you need to make in regard to error handling - the first is "when".  When do you want to deal with errors?  Before the form is submitted or after?  I would suggest to consider dealing with them prior to submit.  Don't even let a user submit a form unless there is a valid set of data to be submitted. 

The next is, how do you want to deal with that scenario?  Error messages, disabled controls, notifications, etc.

 

There are lots of different ways to go about it, but you have full control on how you want it to happen.

Let's take a scenario where you want to validate before submit and yet provide feedback enough to let the user know what they need to do.

 

First, it seems that Edit forms kind of know what they are when first created, but don't update themselves when the underlying datasource is changed.  So, if you create a form and then change fields to be required.  The form will not update to reflect that.  If you remove the fields from the form and add them back in they will then reflect the change (caveat - this will only happen after you get out of the design and back in - even a refresh of the data source while you're in it doesn't seem to update that properly)

SO - that will fix the issue of your forms not providing information about the required fields.  (This might be all you need at this point)

 

Next - the error messages are pretty generic.  You can change them as you have found...set the text as you need.  Now with that, you also need to set (with the Visible property) when that message is displayed.  By default, the Text of the message is set to the Error of the Parent.  This will be whatever the datasource returns as an error.  The visible is set whenever you're in edit mode.  On the label, you can 1) customize the text property and then 2) set the Visible property to (!IsBlank(Parent.Error) && Parent.DisplayMode=DisplayMode.Edit).  

At this point, you will have a custom error message and it will only appear when there is an error.  

It's still a little messy because, you will get this error then for any error that occurs and you'll also get the notification bar about it.

 

If you want to go the next step and get rid of the above mess...then consider disabling the submit button until the form is validated.  You can actually do it a couple ways.  One is to set a formula for the Disabled property of the button/icon.  The other way is to put in some logic to the formula of the button to 1) check for valid  2) if not valid, set a variable and done 3) if valid reset variable and submit the form. Then, with that variable, you can use it for the visible property of the error messages to "turn them on" so the user knows.

 

I realize that last concept paragraph if high-level concept.  I didn't go much deeper because we might have solved your issue at the first solution.  So, if this helps, I am hopeful.  If not, please post back and provide an area you are wanting more detail or having more problems.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Your suggestion was very helpful. I am used to doing a lot of web design validation and the structure of powerapps throws me off a little. I believe using the errors before the submit would be the preferred method, for the users that will be using this form aren't exactly computer savy and I think avoiding the complex validation would be just fine. Your suggestion about updating the datasource, removing the fields, and then readding them worked. I find it very annoying that forms do not update, even after you refresh the datasource connection. Removing fields that I have customized and then readding them back in, just to customize them all over again, becomes very tedious. However, I guess this is just something you have to plan ahead for as a powerapps designer.

 

Thanks for you, RandyHayes, for your help and I appreciate the time you took in helping me, I do love powerapps but some functionality just seems to make me scratch my head at times. 

Amazing!!! I have been online for days and you just make me cry with the advice/solution !! 

Hi Randy,

 

My form is prompting the default SharePoint error warning. In addition to this i would like to add other data validation and show the error respective to it in the same way. For example if the email field is empty when i press the submit button it will prompt the error " Email is required". I also like it to prompt if it is an invalid email too

indhaa_0-1617219632508.png

I don't like to disable the submit button because users tend not to find the mistake in their input. My experience, so would like to prompt the error if the form is invalid. Any input on this?  

 

What I do for this custom error handling:

On the Page with the form: OnVisible, create a context variable to hold a custom message

UpdateContext({emailErr:Blank()});

On the ErrorMessageLabel for the DataCard: set the Text to 
Coalesce(Parent.Error,emailErr) - this takes the first NON-Blank error
In the OnChange event for the field to show the error for

If(<<Logic to determine if error or error message>>, UpdateContext({emailErr:"Invalid Email Address"}), UpdateContext({emailErr:Blank()}))

I then also use the disable of submit by checking that there are no Non-Blank error messages

 

Hi

 

Thanks for the response. This was an old ticket and I have been able to figure it out to give the msg I want without disabling the submit button . I didn't add a new label and just ONLY use the Error card that is already there with the data card. In the text property I use a condition to display what to display depending on the error and in the Update property of the data card I added the condition it will only update if condition is true too. 

@RandyHayes - I'm trying to solve the problem in a different way : I want the validation to be built when the form is actually submitted. So I'm putting this formula in the OnSelect property of the Accept icon - 

If(
DataCardValue14.SelectedDate >= Today() + 7,
SubmitForm(EditForm1),

Now, I'm struggling with setting the error message text label to my desired error text. As a temporary measure, I'm using the Notify() function. But I specifically want to highlight the error against the data card in a bright red text. How do I solve this?

Hi,

 

I have been able to do the customization of the error without a label. The Submit Icon check the Required Property, Update Property of Datacard and will prompt the error as per the Datacard Error msg. So you don't have to add an if condition in the On Select of the Submit button. Just keep it as SubmitForm(EditForm1)

 

So on your Required Property, you can set to true or false up to your requirement. below my example

indhaa_0-1700284660118.png

 

 In the Update Property you can set when to take the value. 
As per your example If(DataCardValue14.SelectedDate >= Today() + 7, DataCardValue14.SelectedDate)

indhaa_1-1700285029259.png

 

In the ErrorMessage , you can set as per your example

If(IsBlank(DataCardValue14),Parent.Error, DataCardValue14.SelectedDate <= Today() + 7, " cannot be less than x days")

 

indhaa_2-1700285225409.png 

indhaa_3-1700285262453.png

 

Hope this help

Anyone knows why the errors are displayed in top of the page instead of being part of a form (displayed inside a form) ? Error Message element is part of a card, common sense would expect it will be visible inside a card....

DariuszSzwabo_0-1706260041951.png

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,157)