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.

8 REPLIES 8
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.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

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

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 49 members 4,059 guests
Please welcome our newest community members: