cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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. 

 

Thanks

Syed Danish

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

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

View solution in original post

1 REPLY 1
Highlighted
Community Support
Community Support

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

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Users online (8,258)