
Announcements
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
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