cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JensVolswinkler
Regular Visitor

ForAll in combination with Collect and Remove from Collection

Can someone explain me the following code-fragment below?

As far as I understand it: 

For every entry in a Gallery with CheckboxAuswählen.Value = true

do the following

Create a collection called titelzeilen and fill it with the current (or with all?) values of Titel from the Gallery

than

update (patch) the Sharepointlist: If the titel in the sharepointlist and the collection titelzeilen is equal set Abgeschickt = true in the sharepointlist

than

remove the first entry of the collection titelzeilen

 

I am wondering:

Collect(titelzeilen;{string:Titel} does this only apply to the current record?

 

Code-Fragment:

ForAll(Filter(Gallery1_Standard.AllItems;CheckboxAuswählen.Value = true);

Collect(titelzeilen;{string:Titel});;
Patch(Sharepointlist;First(Filter(Sharepointlist;Titel=First(titelzeilen).string));{Abgeschickt:true});;

Remove(titelzeilen;First(titelzeilen))

)

 

 

Thanks a lot!

1 ACCEPTED SOLUTION

Accepted Solutions
KvB1
Solution Specialist
Solution Specialist

ForAll(Filter(Gallery1_Standard.AllItems;CheckboxAuswählen.Value = true);

For every gallery item which has a checkbox ticked:

 

Collect(titelzeilen;{string:Titel});;

Add to collection 'titelzeilen', Titel of current record for column 'string'


Patch(Sharepointlist;First(Filter(Sharepointlist;Titel=First(titelzeilen).string));

Grab the first record in 'titelzeilen', and use the value in the string column of that record to find the first match in Sharepointlist, looking for a match in Titel column in Sharepointlist

 

{Abgeschickt:true});;

Update the abgeschikt column of the found record to true

 

Remove(titelzeilen;First(titelzeilen))

Remove the first record in titelzeilen from the collection titelzeilen

 

It's not very pretty. Instead of using First(Filter( you can just use LookUp(. Since you only ever grab the first record from titelzeilen, why bother with a collection at all?

View solution in original post

3 REPLIES 3
KvB1
Solution Specialist
Solution Specialist

ForAll(Filter(Gallery1_Standard.AllItems;CheckboxAuswählen.Value = true);

For every gallery item which has a checkbox ticked:

 

Collect(titelzeilen;{string:Titel});;

Add to collection 'titelzeilen', Titel of current record for column 'string'


Patch(Sharepointlist;First(Filter(Sharepointlist;Titel=First(titelzeilen).string));

Grab the first record in 'titelzeilen', and use the value in the string column of that record to find the first match in Sharepointlist, looking for a match in Titel column in Sharepointlist

 

{Abgeschickt:true});;

Update the abgeschikt column of the found record to true

 

Remove(titelzeilen;First(titelzeilen))

Remove the first record in titelzeilen from the collection titelzeilen

 

It's not very pretty. Instead of using First(Filter( you can just use LookUp(. Since you only ever grab the first record from titelzeilen, why bother with a collection at all?

View solution in original post

It is legacy code and I have to understand it first before I change something^^.

 

Thanks for your answer!

KvB1
Solution Specialist
Solution Specialist

Haha good luck with that, I was looking over the stuff I wrote to make my first app recently, pretty amusing, but I doubt anyone else would understand it

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 (953)