cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ck25415
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
v-xida-msft
Community Support
Community Support

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
v-xida-msft
Community Support
Community Support

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

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 😉

AParker
Frequent Visitor

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,725)