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

Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

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.

10 REPLIES 10
mr-dang
Level 10

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

Hi @seraph787,

Can you look at how the table is setup in Excel--is the date column appearing as a date, value, or text?

Microsoft Employee
@8bitclassroom
seraph787
Level: Powered On

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

It's showing as Date regardless of whether I select the entire column or just that record's field.

Excel CA-MDL-Exp Format.png

seraph787
Level: Powered On

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

Anyone have any ideas?

seraph787
Level: Powered On

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

Is this just a bug?  If it's not verified, maybe someone else can see if they can reproduce the error?

 

Need to have an Excel spreadsheet in Onedrive (for business?) with a table containing a few different columns, one of which contains dates (in 90% of the records?  Leave the other 10% blank) formatted as a date.

 

Use it as a data source in a PowerApps. Import that data source to a Collection.  Then create a gallery and use a datepicker to reference that field.  Use a button to patch the field.  

 

For myself, I can patch changes to the field for records in the collection that already have a date but I can't patch changes to fields that are blank in the collection.

MarcinP
Level: Powered On

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

Hi,

 

I have very similar issue.

 

Local Collection, created from MS SQL Database:

ClearCollect(users_col,'[dbo].[LIST]');

I am not able to patch cell which is NULL in this collection.

 

For example - Collection has 2 columns: USER_ID and USER_VALUE (integer)

below code works only for records where USER_VALUE is not null:

Patch(users_col,First(Filter(users_col,USER_ID=1)),{USER_NAME:1})

I have the same issue with date column.

Any idea?

geortan
Level: Powered On

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

I have the exact same issue with a SQL backend powerapp. Create a local collection on load and if the date is null then the collection will not take a patch.

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

@geortan ,

It sounds like you are trying to patch a collection where there is a null in the date field. Can you enable Formula Level Error management and try it again?

 

@TopShelf-MSFT 

 

image.png

 

PraktikUser
Level: Power Up

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

We experience exactly identical behaviour. If date column already has datetime filled in, patch owrks. if column in given row is NULL, nothing happens.

digiservice
Level: Powered On

Re: Unable to Patch Collection (A Record's Blank Date Field) from DatePicker

Also having this same issue.

 

Patching a datevalue back to a collection which has been collected from a SQL table.

 

We can patch other values just not datetimevalues, nothing happens.

 

If I add a new row to the collection it works and will patch dates. Just can't update existing rows.

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: 271 members 6,456 guests
Please welcome our newest community members: