web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problems with Patching...
Power Apps
Unanswered

Problems with Patching from a Collection

(0) ShareShare
ReportReport
Posted on by 8

I'm creating a collection from selected items in a list box with the code below:

 

 

Collect(colMCCNum, {MCCNum:ListBox1.SelectedItems})

 

 

This creates a single column collection.  I then want to patch rows of the data source HOBOs using the above collection when MCCNum = MCCId and set the Available column to "Checked Out"

 

 

ForAll(colMCCNum, Patch(HOBOs, LookUp(HOBOs, MCCId = MCCNum), {Available:"Checked Out"}))

 

 

 The problem is that in the Look Up function the "=" gets an "Invalid argument type" error.  It seems the MCCNum is not a text value and can't be compared to MCCId but I can't figure out how to fix the code.  Any help would be much appreciated!

Categories:
  • eka24 Profile Picture
    20,925 on at

    Consider this:

    ForAll(colMCCNum, Patch(HOBOs, LookUp(HOBOs,Text(MCCId) = MCCNum), {Available:"Checked Out"}))

    Or

    If MCCNum is a Number type,

    ForAll(colMCCNum, Patch(HOBOs, LookUp(HOBOs, MCCId = Value(MCCNum)), {Available:"Checked Out"}))

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • zaphod88 Profile Picture
    502 on at

    Try

     

     

    ForAll(colMCCNum, Patch(HOBOs, LookUp(HOBOs, Value(MCCId) = colMCCNum[@MCCNum]), {Available:"Checked Out"})

     

     

  • dstortz Profile Picture
    8 on at

    I got the same error when I tried:


    @eka24 wrote:

    Consider this:

    ForAll(colMCCNum, Patch(HOBOs, LookUp(HOBOs,Text(MCCId) = MCCNum), {Available:"Checked Out"}))

     


    I got a "Incompatible Type" error at the "=" and "The function 'Value' has some invalid arguments.", "Expected text or number. we expect text or a number at this point in the formula." when I tried this one:


    @eka24 wrote:

    If MCCNum is a Number type,

    ForAll(colMCCNum, Patch(HOBOs, LookUp(HOBOs, MCCId = Value(MCCNum)), {Available:"Checked Out"}))

     

     


     

  • dstortz Profile Picture
    8 on at

    I got the same error as before and the [@Value] returned "Name isn't valid" error.

  • dstortz Profile Picture
    8 on at

    Another odd thing I noticed, was that when I view my collections, the colMCCNum shows up with a table icon.  If I click the icon is shows the column of data.  This is the only collection that does this.

    colMCCNum01.jpgcolMCCNum02.jpg

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dstortz 

    Please consider changing your Formula to the following:

    Patch(HOBOs, 
     ForAll(ListBox1.SelectedItems, 
     LookUp(HOBOs, MCCId = MCCNum), 
     {Available:"Checked Out"}
     )
    )

     

    There is no need to waste the Table that you create with the ForAll function that is designed to produce tables.  Patch will accept it without issue.

     

    Also, if MCCId is the primary key column of your list, then you can simplify even further to:

    Patch(HOBOs, 
     ForAll(ListBox1.SelectedItems, 
     {MCCId = MCCNum, 
     Available:"Checked Out"
     }
     )
    )

    Patch is smart enough to know to patch the row with that primary key if you supply it...and it is MUCH quicker to execute. 

     

    I hope this is helpful for you.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 383 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard