Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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! 

 

 

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 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard