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

Required condtion not working with Patch

Hi,

 

Lets say that I have a data table dtData with multiple dimensions (around 100). I have distributed 100 dimensions into 4 forms and inserting a record in the data table using Patch Function

 

Patch(dtData, Defaults(dtData),Form1.Updates, Form2.Updates, Form3.Updates, Form4.Updates)

 

In each forms, I have few fields where I have set Required settings as true but it is not working the way it works with Submitform function. Even though the required fields are blank, the Patch function allows to create a new record in the data table.

 

Please advise.

 

Thanks,

Vivek

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Required condtion not working with Patch

Hi @vranjan22,

I think you have some misunderstanding with SubmitForm function and Patch function.

If you use SubmitForm function to submit your form data, before submitting any changes, this function checks for validation issues with any field that's marked as required or that has one or more constraints on its value.

If you use Patch function to submit your form data, this function would not check for validation issues with any field that's marked as required.

More details about SubmitForm function and Patch function, please check the following article:

SubmitForm function

Patch function

As an alternative solution, I agree with @Drrickryp's thought almost. You could consider take a try to check if the required field contains values before Patching your form datas, if not, disable the "Submit" button.

Please take a try with the following workaround:

Set the DisplayMode property of the "Submit" button to following formula:

If(
IsBlank(DataCardValue1.Text) ||
IsBlank(DataCardValue2.Text) ||
...
IsBlank(DataCardValue7.Text) ||
...
,
DisplayMode.Disabled,
DisplayMode.Edit
)

Note: The DataCardValue1, DataCardVlaue2, DataCardValue7, ... represents the Text Input controls related to the required fields in your Edit form.

You could also take a try with the following workaround:

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

If(
!IsBlank(DataCardValue1.Text) &&
!IsBlank(DataCardValue2.Text) &&
...
!IsBlank(DataCardValue7.Text) &&
...,
Patch(dtData, Defaults(dtData),Form1.Updates, Form2.Updates, Form3.Updates, Form4.Updates)
)

Best regards,

Kris

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.
3 REPLIES 3
Super User
Super User

Re: Required condtion not working with Patch

@vranjan22,

I am not sure how to fix the patch function but you could set the DisplayMode property of the button you are using for the patch to be disabled if any of your required fields are blank. 

 

If(Or(IsBlank(TextInput1), IsBlank(TextInput2), IsBlank(TextInput3)), DisplayMode.Disabled, DisplayMode.Edit)

 

You could set the HInt text on the button to "The form cannot be saved until all the required fields are filled".  If this works for you please mark the thread as solved.

Community Support Team
Community Support Team

Re: Required condtion not working with Patch

Hi @vranjan22,

I think you have some misunderstanding with SubmitForm function and Patch function.

If you use SubmitForm function to submit your form data, before submitting any changes, this function checks for validation issues with any field that's marked as required or that has one or more constraints on its value.

If you use Patch function to submit your form data, this function would not check for validation issues with any field that's marked as required.

More details about SubmitForm function and Patch function, please check the following article:

SubmitForm function

Patch function

As an alternative solution, I agree with @Drrickryp's thought almost. You could consider take a try to check if the required field contains values before Patching your form datas, if not, disable the "Submit" button.

Please take a try with the following workaround:

Set the DisplayMode property of the "Submit" button to following formula:

If(
IsBlank(DataCardValue1.Text) ||
IsBlank(DataCardValue2.Text) ||
...
IsBlank(DataCardValue7.Text) ||
...
,
DisplayMode.Disabled,
DisplayMode.Edit
)

Note: The DataCardValue1, DataCardVlaue2, DataCardValue7, ... represents the Text Input controls related to the required fields in your Edit form.

You could also take a try with the following workaround:

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

If(
!IsBlank(DataCardValue1.Text) &&
!IsBlank(DataCardValue2.Text) &&
...
!IsBlank(DataCardValue7.Text) &&
...,
Patch(dtData, Defaults(dtData),Form1.Updates, Form2.Updates, Form3.Updates, Form4.Updates)
)

Best regards,

Kris

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.
vranjan22
Level 8

Re: Required condtion not working with Patch

Thank you @v-xida-msft @Drrickryp

 

I have applied the suggestion and it is working for me.

 

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 152 members 4,244 guests
Recent signins:
Please welcome our newest community members: