cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Figment98
New Member

Dropdown and date picker resetting to default in gallery when saving line.

Hello - I'm new to PowerApps, but I've been able to figure out a lot of things using this forum (thanks!) and google searches.  I'm building an expense report, which uses a form (for the report) and a gallery (for the line items), and I'm running into a snag that has me stumped.  

 

The gallery has a number of input fields: a DatePicker, a DropDown for category, and then a number of text fields.  When I save the row, the correct values are patching to the collection, BUT they reset to the default on the screen.  I can't figure out how to get the DatePicker and DropDown fields to retain their original value on the screen.  The user is going to think the wrong data will submit in the report.    

 

Here's the code that I'm using to patch the line to the collection and add a new line.  Anything jump out in there?

 

Patch(ExpenseCollection,ThisItem,{LineItem: InputItem.Text,LineCost: Value(InputCost.Text),Miles: Value(InputMiles.Text),MilesCost: Value(CalcMileage.Text),ExpDate:DatePicker1.SelectedDate,Category:Dropdown1.Selected.Value,ShowSaveButton:false}); Collect(ExpenseCollection,{LineItem:"",LineCost: 0,Miles: 0,MilesCost: 0,Category:"",ExpDate:Today(),ShowSaveButton: true})  

 

Or do I perhaps need to do something on the Dropdown and DatePicker properties?  I'm at a loss here.  

 

Thanks for any help you can offer!

1 ACCEPTED SOLUTION

Accepted Solutions
Figment98
New Member

Figured it out.  🙂  The Default on those needs to be ThisItem.ExpDate and ThisItem.Category.  No clue why, but it works now.  🙂  

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@Figment98 

What is the DefaultDate property set to on the DatePicker and what is the Default set to on the Dropdown?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Figment98
New Member

Figured it out.  🙂  The Default on those needs to be ThisItem.ExpDate and ThisItem.Category.  No clue why, but it works now.  🙂  

RandyHayes
Super User
Super User

@Figment98 

Yep, that is where I was going!  When you change anything about the datasource (Items) of your Gallery, it will reevaluate the controls in it.  If they have no Default properties set, they will default to blank or something you don't want.  You have to set them.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Figment98
New Member

Yes, thanks for the explanation.  Appreciate it.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,309)