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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Issue getting the curr...
Power Apps
Unanswered

Issue getting the current item in iteration

(0) ShareShare
ReportReport
Posted on by 5

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. 

 

Thanks

Syed Danish

I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    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

     

    ForAll(
     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,

    Bof

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard