cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Required field error message not displayed when using Patch command

Hello,

 

I have a powerapps form with submit button onselect having a patch function tthat creates a new item. The required fields dont show error message when I use the patch function however they do show up when I use submitform function on the onselect property of the submit button . Is this expected behaviour ?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Required field error message not displayed when using Patch command

Hi @ck25415 ,

Where do you specify your fields as Required? Within your data source itself or the Edit form?

Could you please share a bit more about the error message within your app?

Further, could you please show more details about the Patch formula you used within your app?

 

1. If you specify your fields as Required within data source itself, when you do not provide a valid value for the Required fields in your data source, and execute the Patch function, the following error would show up:1.JPG

In other words, your Patch function would not be executed successfully, the new record would not be added into your data source.

If you want the error message to display when you execute the Patch function in your running app (in Player mode), please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

If(
    !IsEmpty(Errors('20190611_case8',Patch('20190611_case8', Defaults('20190611_case8'),{Title: "PowerApps R"}))),
    Notify(First(Errors('20190611_case8')).Column & " " & First(Errors('20190611_case8')).Message, NotificationType.Error)
)

On your side, you should type following:

If(
    !IsEmpty(
Errors(
'YourDataSource',
Patch('YourDataSource', Defaults('YourDataSource'),{Title: "PowerApps R"}) /* <-- Type your Patch formula here */
)
), Notify(First(Errors('YourDataSource')).Column & " " & First(Errors('20190611_case8')).Message, NotificationType.Error) )

Please check the following GIF screenshot for more details:Test.gif

 

 

2. If you just specify the fields as Required within your Edit form via setting the Required property of the corresponding Data cards in your Edit form, when you execute the Patch function, the error message would not show up.

As an alternative solution, you could add a If function to your formula, to check if the specified Required field is not populated with values, if true, show an error message:

Set the OnSelect property of the "Submit" button to following:

If(
   IsBlank(DataCardValue1.Text),        /* <-- Check if the specific Required field text box is populated with values */
   Notify("The Column1 is a Required field, please type a valid value within it!", NotificationType.Error),
IsBlank(DataCardValue2.Text),
Notify("The Column2 is a Required field, please type a valid value within it!", NotificationType.Error),
...
... Patch('YourDataSource', Defaults('YourDataSource'),{Title: "PowerApps R"}) /* <-- Type your Patch formula here */ )

More details about the Errors function, please check the following article:

Errors function

 

Best regards,

Community Support Team _ Kris Dai
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

3 REPLIES 3
Highlighted
Community Support
Community Support

Re: Required field error message not displayed when using Patch command

Hi @ck25415 ,

Where do you specify your fields as Required? Within your data source itself or the Edit form?

Could you please share a bit more about the error message within your app?

Further, could you please show more details about the Patch formula you used within your app?

 

1. If you specify your fields as Required within data source itself, when you do not provide a valid value for the Required fields in your data source, and execute the Patch function, the following error would show up:1.JPG

In other words, your Patch function would not be executed successfully, the new record would not be added into your data source.

If you want the error message to display when you execute the Patch function in your running app (in Player mode), please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

If(
    !IsEmpty(Errors('20190611_case8',Patch('20190611_case8', Defaults('20190611_case8'),{Title: "PowerApps R"}))),
    Notify(First(Errors('20190611_case8')).Column & " " & First(Errors('20190611_case8')).Message, NotificationType.Error)
)

On your side, you should type following:

If(
    !IsEmpty(
Errors(
'YourDataSource',
Patch('YourDataSource', Defaults('YourDataSource'),{Title: "PowerApps R"}) /* <-- Type your Patch formula here */
)
), Notify(First(Errors('YourDataSource')).Column & " " & First(Errors('20190611_case8')).Message, NotificationType.Error) )

Please check the following GIF screenshot for more details:Test.gif

 

 

2. If you just specify the fields as Required within your Edit form via setting the Required property of the corresponding Data cards in your Edit form, when you execute the Patch function, the error message would not show up.

As an alternative solution, you could add a If function to your formula, to check if the specified Required field is not populated with values, if true, show an error message:

Set the OnSelect property of the "Submit" button to following:

If(
   IsBlank(DataCardValue1.Text),        /* <-- Check if the specific Required field text box is populated with values */
   Notify("The Column1 is a Required field, please type a valid value within it!", NotificationType.Error),
IsBlank(DataCardValue2.Text),
Notify("The Column2 is a Required field, please type a valid value within it!", NotificationType.Error),
...
... Patch('YourDataSource', Defaults('YourDataSource'),{Title: "PowerApps R"}) /* <-- Type your Patch formula here */ )

More details about the Errors function, please check the following article:

Errors function

 

Best regards,

Community Support Team _ Kris Dai
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

Highlighted
Super User
Super User

Re: Required field error message not displayed when using Patch command

Hi @ck25415 

 

Please see below video which I think could be of help to you as you could use the Valid property on cards and forms to check for required fields.

https://youtu.be/7O8HCz37Q0A

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions. AND we get points for it 😉

Highlighted
Frequent Visitor

Re: Required field error message not displayed when using Patch command

I know this is old and solved, but I struggled with the same error and it ended up being an issue with formula-level error management. Turning off this option fixed my app.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (12,164)