Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Answered

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

Categories:
  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    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

     

    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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Microsoft Dataverse

#1
stampcoin Profile Picture

stampcoin 17

#2
mmbr1606 Profile Picture

mmbr1606 15 Super User 2025 Season 1

#3
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

Overall leaderboard

Featured topics