Showing results for 
Search instead for 
Did you mean: 
New Member

Issue getting the current item in iteration

Hello Guys,


I have an issue iterating the items in ForAll(). Here is the brief requirement that we are trying to achieve.


We have a gallery with check boxes, based on the selection we would like to insert the checked items of a gallery into an entity. For check and uncheck of the check boxes we are adding and removing items from a collection and looping that collection using ForAll.


How would I get the current item from the collection which is under iteration. 


ForAll(SelectedOptions, Patch('Assessments',Defaults('Assessments'),{Employee: LookUp(Contacts, Contact=ContactID), Option:Last(LoopedItem)}))


In the above formula I would like to add the current item under iteration in option.


Any help would be highly appreciated. 



Syed Danish


Re: Issue getting the current item in iteration

Hi @syed_aalam001 :

Do you want to get the current item in iteration?

The key is to use the lookup function to find the corresponding item in the loop body.

I assume ‘Value' is a field in the data source “SelectedOptions” and can be used as a unique identifier.

I adjusted the code for your reference


 RenameColumns(SelectedOptions,"Value","Valuee"),/*Create temporary tables and change field names to eliminate ambiguity*/
 Patch('Assessments',Defaults('Assessments'),{Employee: LookUp(Contacts, Contact=ContactID), Option:LookUp(SelectedOptions,Value=Valuee)}) /*LookUp(SelectedOptions,Value=Valuee) is the current item in iteration*/


My idea is to use a unique identifier to match and find the corresponding record.Because two tables have the same field names, this will cause ambiguity, so I used RenameColumns (which does not change the data source) at the beginning to modify the field names to eliminate ambiguity.

Best Regards,


Helpful resources

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...


New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Users online (6,112)