cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HawkinsGabriel
Level: Powered On

How to stop data cards from resetting from resetting between Patch submissions

So I created a form to add rows to an excel table, using multiple data cards of with various controls.  The basic purpose was to have employees submit requests to be added to a specific project number.

 

In order to allow for submitting multiple rows at once (multiple employees to one project number, or vice versa), I used multiple patch functions.  For example, on my form for multiple employees to be added to request addition to a single project number,  I have five sets of the same few data cards for five employees, and one set of data cards for the specific project number, and I use a patch function for each employee (so if I add five employees, I use five patch functions, each with a different set of data cards for the employees, but the same set of data cards for the project number).

 

The issue is that four of the data cards' values reset to ther default values after the first patch in the same OnSelect operation - two datepicker controls, a label used to display the current time, a slider for how many hours a week they would work.  So if I add two employees at once, the second row/employee will reset to the default values on the second row.  Is there any way to stop it from resetting in between Patch functions?

 

Here is the OnSeleft formula for adding teo employees, highlighting the datacards the default after the first Patch -

Patch(PN_Requests,ThisItem,{Associate: AssDataCardValue.Text, Associate_x0020_ID: AssIDDataCardValue.Text, Team: Dropdown1.Selected.Value, Request: Dropdown7.Selected.Value, Client_x0020_Mnemonic: DataCardValue4.Text, Project_x0020_Number: DataCardValue5.Text, Solution: DataCardValue6.Text, Role: DataCardValue12.Text, Start_x0020_Date: DatePicker3.SelectedDate, End_x0020_Date: DatePicker4.SelectedDate, Est_x002e__x0020_Hours_x0020_per_x0020_Week: Slider1.Value, Replacing_x0020_or_x0020_Assisting_x003f_: Dropdown8.Selected.Value, Submitted: Label28.Text});Patch(PN_Requests,ThisItem,{Associate: TextInput2.Text, Associate_x0020_ID: TextInput3.Text, Team: Dropdown2.Selected.Value, Request: Dropdown7.Selected.Value, Client_x0020_Mnemonic: DataCardValue4.Text, Project_x0020_Number: DataCardValue5.Text, Solution: DataCardValue6.Text, Role: TextInput4.Text, Start_x0020_Date: DatePicker3.SelectedDate, End_x0020_Date: DatePicker4.SelectedDate, Est_x002e__x0020_Hours_x0020_per_x0020_Week: Slider1.Value, Replacing_x0020_or_x0020_Assisting_x003f_: Dropdown8.Selected.Value, Submitted: Label28.Text});

3 REPLIES 3
Highlighted
CMee
Level: Powered On

Re: How to stop data cards from resetting from resetting between Patch submissions

I might suggest that prior to your patch functions you store the values that are being reset as local variables and using those in your patch functions, that way it wouldn't matter if the datacard is reset. Something like the following.

 

UpdateContext({StartDateValue: DatePicker3.SelectedDate});
UpdateContext({EndDateValue: DatePicker4.SelectedDate});
UpdateContext({EstHoursPerWeekValue: Slider1.Value});
UpdateContext({SubmittedValue: Label28.Text});

Patch(PN_Requests,ThisItem,{
	Associate: AssDataCardValue.Text, 
	Associate_x0020_ID: AssIDDataCardValue.Text, 
	Team: Dropdown1.Selected.Value, 
	Request: Dropdown7.Selected.Value, 
	Client_x0020_Mnemonic: DataCardValue4.Text, 
	Project_x0020_Number: DataCardValue5.Text, 
	Solution: DataCardValue6.Text, 
	Role: DataCardValue12.Text, 
	Start_x0020_Date: StartDateValue, 
	End_x0020_Date: EndDateValue, 
	Est_x002e__x0020_Hours_x0020_per_x0020_Week: EstHoursPerWeekValue, 
	Replacing_x0020_or_x0020_Assisting_x003f_: Dropdown8.Selected.Value, 
	Submitted: SubmittedValue}
);
Patch(PN_Requests,ThisItem,{
	Associate: TextInput2.Text, 
	Associate_x0020_ID: TextInput3.Text, 
	Team: Dropdown2.Selected.Value, 
	Request: Dropdown7.Selected.Value, 
	Client_x0020_Mnemonic: DataCardValue4.Text, 
	Project_x0020_Number: DataCardValue5.Text, 
	Solution: DataCardValue6.Text, 
	Role: TextInput4.Text, 
	Start_x0020_Date: StartDateValue, 
	End_x0020_Date: EndDateValue, 
	Est_x002e__x0020_Hours_x0020_per_x0020_Week: EstHoursPerWeekValue, 
	Replacing_x0020_or_x0020_Assisting_x003f_: Dropdown8.Selected.Value, 
	Submitted: SubmittedValue}
);
HawkinsGabriel
Level: Powered On

Re: How to stop data cards from resetting from resetting between Patch submissions

This worked to stop the values from resetting in between the patch functions!

 

However, it does reset those values to their defaults AFTER the the patch functions.  This would not be a problem, except the datepicker controls show the previously selected dates instead of the default dates, and if I were to hit the submit button again (with said patch functions) without changing anything, the excel table is updated with the default date values instead of the previously selected values which display in the powerapps form.

 

I can just add reset formulas for those controls, but is there a way to stop the controls from resetting at all?

Community Support Team
Community Support Team

Re: How to stop data cards from resetting from resetting between Patch submissions

Hi @HawkinsGabriel,

 

I agree with @CMee's thought almost, if you want to stop all these controls within your form from resetting at all, you should set the Reset property of all the controls to false.

DatePicker3.Reset=false

DatePicker4.Reset=false

Slider1.Reset=false

Label28.Reset=false

In addition, set the Default property of all these controls to corresponding local variables value:

DatePicker3.Default=StartDateValue

DatePicker4.Default=EndDateValue

Slider1.Default=EstHoursPerWeekValue

Label28.Default=SubmittedValue

The OnSelect property of the Submit button set to following formula (which the user @CMee provided):

UpdateContext({StartDateValue: DatePicker3.SelectedDate});
UpdateContext({EndDateValue: DatePicker4.SelectedDate});
UpdateContext({EstHoursPerWeekValue: Slider1.Value});
UpdateContext({SubmittedValue: Label28.Text});

Patch(PN_Requests,ThisItem,{
	Associate: AssDataCardValue.Text, 
	Associate_x0020_ID: AssIDDataCardValue.Text, 
	Team: Dropdown1.Selected.Value, 
	Request: Dropdown7.Selected.Value, 
	Client_x0020_Mnemonic: DataCardValue4.Text, 
	Project_x0020_Number: DataCardValue5.Text, 
	Solution: DataCardValue6.Text, 
	Role: DataCardValue12.Text, 
	Start_x0020_Date: StartDateValue, 
	End_x0020_Date: EndDateValue, 
	Est_x002e__x0020_Hours_x0020_per_x0020_Week: EstHoursPerWeekValue, 
	Replacing_x0020_or_x0020_Assisting_x003f_: Dropdown8.Selected.Value, 
	Submitted: SubmittedValue}
);
Patch(PN_Requests,ThisItem,{
	Associate: TextInput2.Text, 
	Associate_x0020_ID: TextInput3.Text, 
	Team: Dropdown2.Selected.Value, 
	Request: Dropdown7.Selected.Value, 
	Client_x0020_Mnemonic: DataCardValue4.Text, 
	Project_x0020_Number: DataCardValue5.Text, 
	Solution: DataCardValue6.Text, 
	Role: TextInput4.Text, 
	Start_x0020_Date: StartDateValue, 
	End_x0020_Date: EndDateValue, 
	Est_x002e__x0020_Hours_x0020_per_x0020_Week: EstHoursPerWeekValue, 
	Replacing_x0020_or_x0020_Assisting_x003f_: Dropdown8.Selected.Value, 
	Submitted: SubmittedValue}
);

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.

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
Users Online
Currently online: 192 members 5,433 guests
Please welcome our newest community members: