For some reason, no matter what I do, I can't get my OnSelect to patch any type of value (data, text, value) to a blank date field in a record of a local collection.
The local collection is called cpaDB and it is generated by importing an Excel table into PowerApps. The collection shows up perfectly in my gallery. When I try to update a date value in it, nothing happens.
- Formula 1: Patch(cpaDB,ThisItem,{'CA-MD-Lic-Exp': DatePicker2.SelectedDate})
I have tried patching the exact same DatePicker to a text field and that works so I then tried
- Formula 2: Patch(cpaDB,ThisItem,{'CA-MD-Lic-Exp': Text(DatePicker2.SelectedDate)})
To see if my CA-MD-Lic-Exp field was being read as text instead of a date, but then i get an error of:
"The type of this argument 'CA-MD-Lic-Exp' does not match the expected type 'DateTime'. Found type 'Text'."
Considering it would do NOTHING with the above Formula 1, and it throws an error with Formula 2, I went ahead and tried passing it as a value, which (as expected) didn't do anything to help.
I then tried to use DateTimeValue()
- Formula 3: Patch(cpaDB,ThisItem,{'CA-MD-Lic-Exp': DateTimeValue(DatePicker2.SelectedDate)})
But this said it was expecting a text value for the DateTimeValue
So I wrapped the selected date in Text()
- Formula 4: Patch(cpaDB,ThisItem,{'CA-MD-Lic-Exp': DateTimeValue(Text(DatePicker2.SelectedDate,ShortDate))})
No error but it does nothing...
This seems like an incredibly simple thing (I just want to pass the date from the datepicker into the CA-MD-Lic-Exp field in my local collection) so I must be missing something incredibly obvious?
Note: Out of curiousity, I went to another record where the CA-MD-Lic-Exp field was not blank (it contained one of the dates exported into it from Excel) and I was able to patch it with the datepicker value successfully using Formula 1.