Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Can no longer Patch a simple collection?

(0) ShareShare
ReportReport
Posted on by 106

Can someone tell me why the below collection will not submit?

 

The issue is specifically with the column Five portion of the collection as it was submitting before I added this.

 

The patch code has the red X beside the submit button, but it isn’t clear why it’s wrong. If I view the collection I can see the date stored there just fine.

 

Collection code:

 

Collect(Col1, {One: Country_1.Selected.Value, Two: Text(DateOut_1.SelectedDate,"dd/mm/yyyy"), Three: Text(DateBack_1.SelectedDate,"dd/mm/yyyy"), Four: Reason_1.Selected.Value, Five: Text(Today(),"dd/mm/yyyy")})

 

Submit button OnSelect code:

 

Patch('Travel Notification', ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));

Categories:
  • timl Profile Picture
    timl 34,222 on at
    Re: Can no longer Patch a simple collection?

    Hi @elfreddos 

    Assuming that the data types of Date_Departure and Date_Return are dates, you would need to call DateValue to convert the Text dates to Date objects:

    Patch('Travel Notification', 
     ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: DateValue(_Data.Two), Date_Return: DateValue(_Data.Three), Reason: _Data.Four, Date_Created: DateValue(_Data.Five)})
    );

     

    As I mentioned in your other post, saving DatePicker.SelectedDate to a collection saves a Date object to the collection. I would recommend that you stick with this approach. If you're seeing US dates in the collection view, the probable reason for this is that your browser is set to US English.

     

    If you build the collection like so, the Patch should hopefully work.

     

    Collect(Col1, {One: Country_1.Selected.Value, Two: DateOut_1.SelectedDate,
     Three: DateBack_1.SelectedDate, Four: Reason_1.Selected.Value, 
    Five: Today()})
    Patch('Travel Notification', ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));

     

  • mmbr1606 Profile Picture
    mmbr1606 10,448 on at
    Re: Can no longer Patch a simple collection?

    hey @elfreddos 

     

    for collection try:

    Collect(Col1, {One: Country_1.Selected.Value, Two: Text(DateOut_1.SelectedDate,"dd/mm/yyyy"), Three: Text(DateBack_1.SelectedDate,"dd/mm/yyyy"), Four: Reason_1.Selected.Value, Five: Text(Today(),"dd/mm/yyyy")})

     

    patch:

    Patch('Travel Notification', ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Re: Can no longer Patch a simple collection?

    Could you please show me error details?

     

  • elfreddos Profile Picture
    elfreddos 106 on at
    Re: Can no longer Patch a simple collection?

    Thanks for that! The column is a date/time column in SharePoint but with Date Only display.

     

    Unfortunately, that code you sent over also doesn't work. It throws up a red line from the "patch" portion.

  • Re: Can no longer Patch a simple collection?

    Hi @elfreddos ,

     

    Do you mean that Patch function doesn't work?

    Could you please tell me the type of Date_Created column and database?

    Or you can try this first:

    ForAll(Col1 As _Data,Patch('Travel Notification',Defaults('Travel Notification'),{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));

     

     

    Best regards,

    Rimmon

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard