cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ck25415
Level 8

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
Community Support Team
Community Support Team

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

2 REPLIES 2
Community Support Team
Community Support Team

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

Dawidvh
Level 10

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 😉

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (7,216)