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 / Loop through a collect...
Power Apps
Unanswered

Loop through a collection from Flow and patch with filtered list

(0) ShareShare
ReportReport
Posted on by 90

Hi, I poked around with the following codes but still can't make it work. Can someone help? 

Each Process is associated with multiple BOMs. I get the data from flow (SQL Sproc) and would like to associate the BOMs with the corresponding Process before displaying on the gallery. 

 

Below doesn't work, but hope you get the idea: 

ClearCollect(OpenProcesses,GetOpenWorkOrderProcessesBySourceType.Run("2"));
ClearCollect(OpenProcessBOMs,GetOpenWorkOrderProcessesBOMBySourceType.Run("2"));
UpdateContext({tempCollection: OpenProcesses});            //i need to create a temp collection so ForAll can work properly
ForAll(tempCollection,
    Patch(OpenProcesses, ThisRecord,
        { BOM: Filter(OpenProcessBOMs, WorkOrderId = ThisRecord.WorkOrderId, SerialNumber = ThisRecord.SerialNumber)}
    )
);

 

Where i think are problematic: 

1. It seems like I can't create a new field "BOM" and make it associate to the Process item? If i simply set the changeRecord argument to {PONumber: Rand()} where PONumber is an existing field, the error message goes away. 

2. I don't think I can use the Filter function inside Patch. It seems only prefer constant value. Then what should i do? All i want is to go through each item in my OpenProcesses collection, look up the BOM items that have the same WorkOrderId and SerialNumber with the current Process item, and stored this BOM list inside a new field called "BOM". When I build the "Process" gallery, i want to be able to do "ThisItem.BOM". 

 

Thank you for your help! 

 

 

Categories:
I have the same question (0)

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 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard