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 / For All Checking and U...
Power Apps
Unanswered

For All Checking and Updating SharePoint List

(0) ShareShare
ReportReport
Posted on by 46

Hey All,

 

I am having trouble getting this to work.

I have a SharePoint list that i am updating/adding contents to depending of whether or not the content is already present.

However I keep getting an error on the second lookup Function

 

 

 

ForAll(colApr,If(IsBlankOrError(Filter(LAST_ORDER_PO,ITEM_SKU).ITEM_SKU),
Patch(LAST_ORDER_PO, Defaults(LAST_ORDER_PO), {
Title:ITEM_SKU,
ITEM_SKU:ITEM_SKU,
QTY:Value(TextInput2.Text),
DATE: Now()

}),

Patch(LAST_ORDER_PO, LookUp(LAST_ORDER_PO,ITEM_SKU = ThisRecord.ITEM_SKU), {
QTY:Value(TextInput2.Text),
DATE: Now()

})

));

 

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @4wordsback 

    There are some issues with your formula.

    1)  ForAll is a table returning function, not a For/Loop like in a programing environment.

    2)  Your Filter in the first part is going to return a table, not an individual item.

    3)  Your lookup at the end to patch a record is going to always pick just the first item it finds.  If I look at your formula properly, I suspect you might have more than one.

     

    Please consider changing your Formula to the following:

    Patch(LAST_ORDER_PO, 
     ForAll(colApr, 
     {
     ID: ID,
     Title: ITEM_SKU,
     ITEM_SKU: ITEM_SKU,
     QTY: Value(TextInput2.Text),
     DATE: Now()
     }
     )
    )
    

    If your colApr collection contains the ID of the original record or a Blank ID if it is new, then the above will do what you need. 

    First, ForAll will return a table of records.  Each record will have the values you want, but more significantly, will have the ID of the original record.  That ID will (should be) blank if it is new. 

    Next, this table is passed to Patch which will patch the entire table to your list.  Patch is smart enough to know that if the primary key (ID in this case) is blank, then it will create a record.  If it is not blank, then it will update the existing record.

     

    Nothing more needed!

     

    I hope this is helpful for you.

     

  • 4wordsback Profile Picture
    46 on at

    Thank 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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard