Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Collection vs Patch

(0) ShareShare
ReportReport
Posted on by 725

Hi everyone

This works

Patch(BSInspections,Defaults(BSInspections),{StationNum:{Id:NumT.ID, Value:NumT.StationNumber}},{BaitLeft:BLeft},{BaitAdded:BAdded},{Faeces:FaecesYN},{InspectionDate:Today()})

But this does not

Collect(ColStation,{StationNum:{Id:NumT.ID, Value:NumT.StationNumber}},{BaitLeft:BLeft},{BaitAdded:BAdded},{Faeces:FaecesYN},{InspectionDate:Today()})

 BLeft, BAdded, Faeces are  true false Set() variables, Do Collections not like Set() variables? I'm not getting errors but the collection just shows the date and BLeft, BAdded, Faeces all as false.

Thank you for your time.

Categories:
  • R Bakker Profile Picture
    R Bakker 725 on at
    Re: Collection vs Patch

    Thank you timl, this works well

  • Verified answer
    timl Profile Picture
    timl 34,377 on at
    Re: Collection vs Patch

    @Corissandageri 

    Syntactically, this formula adds a new record to BSInspections. It merges all the fields that you specify after Defaults(BSInspections) into a single new record.

    Patch(BSInspections,Defaults(BSInspections),{StationNum:{Id:NumT.ID, Value:NumT.StationNumber}},{BaitLeft:BLeft},{BaitAdded:BAdded},{Faeces:FaecesYN},{InspectionDate:Today()})

    In contrast, this function would add 5 records to the ColStation collection. Therefore, these two calls are not equivalent.

    Collect(ColStation,{StationNum:{Id:NumT.ID, Value:NumT.StationNumber}},{BaitLeft:BLeft},{BaitAdded:BAdded},{Faeces:FaecesYN},{InspectionDate:Today()})

    The formula beneath would behave the same as your Patch example.

    Collect(ColStation,
     {StationNum:{Id:NumT.ID,Value:NumT.StationNumber},
     BaitLeft:BLeft,
     BaitAdded:BAdded,
     Faeces:FaecesYN,
     InspectionDate:Today()
     }
    )

     

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,636

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,942

Leaderboard