cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ashok2
Post Patron
Post Patron

bulk update records in PowerApps from checkbox selection

I want to update bluk record in sharepoint using powerapp gallery 

 

I have created gallery and added check box inside gallery and written below formula 

OnCheck property of Gallery >If(IsBlank(LookUp(CheckedItems, 'SID'=ThisItem.'SID')),Collect(CheckedItems,LookUp(CheckedItems, 'SID'=ThisItem.'SID')))
OnUncheck:If(!IsBlank(LookUp(CheckedItems,'SID'=ThisItem.'SID')),Remove(CheckedItems,LookUp(CheckedItems, 'SID'=ThisItem.'SID')))


Now on Button select i want to update status Done for all checked check box item, writting below formula but not working getting error = inavlid arguemnt type

 

ForAll(CheckedItems,Patch(SPTest,LookUp(SPTest,'SID'=CheckedItems[@SID]),{Status:{Value:"Done"}}))

6 REPLIES 6
poweractivate
Community Champion
Community Champion

@Ashok2 

 

Square brackets are not used to access the record in PowerApps as per your usage CheckedItems[@SID], they are used only sometimes to initialize a collection. Therefore that is not valid usage. In some programming languages this could be the case but PowerApps does not access Table elements by Index using the square brackets. Consider Something like this example:

 

Suppose a Collection called SomeCollection

 

You cannot say SomeCollection[1] to access index 2 of SomeCollection.

Instead, use something like Last( FirstN(SomeCollection,2) ) to access the 2nd element of SomeCollection

 

Also in ForAll the formula is evaluated on each record, so the record does not have to be fetched with array index notation (which again, we do not believe array index notation is currently how PowerApps works).

 

Try reframing it another way assuming that ForAll's second parameter, the Formula, already is context aware - because the Formula is evaluated in each record of the provided Table according to https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-forall

gabibalaban
Super User II
Super User II

The bold text is a syntax error. You can write {Status:"Done"}, i think it will be enough.

ForAll(CheckedItems,Patch(SPTest,LookUp(SPTest,'SID'=CheckedItems[@SID]),{Status:{Value:"Done"}}))

 

Please be carefull that this approach (with lookup for Sharepoint list  inside a patch in forall loop) might give you a delegation warning. Isn't so ? (a small yellow icon near the button).

I get error here
,'SID'=CheckedItems[@SID]), in equal and correct delegation warning as well if it's not recommended what else can be used?

I don't think you need the qoutes: SID=CheckedItems[@SID])

[@SID] Name isnt valid :the identifer isn't recognized error and delegaton as well , can i change this formula to get expected result

@poweractivate  

 

Yes its correct i reframed my formula to below  and it is working as expected

 

ForAll(RenameColumns(Filter(Gallery.AllItems,Checkbox3_1.Value),"ID","ID1"),Patch(SPList,LookUp(SPList,ID=ID1),{Status:{Value:"Done"}}))

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (3,380)