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,
Solved! Go to Solution.
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:
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:
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:
Best regards,
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:
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:
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:
Best regards,
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.
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 😉
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.