I am brand new to Flow and I need to create a decision element based on criteria from a child record’s related records, or more specifically, from the Opportunity\Opportunity Line Items\Product2 field values.
Per the Product and Schedule Object’s entity relationship diagram (ERD), you can get to Product2 through the OpportunityLineItem via the PricebookEntry object, but in reality the Product2ID is available on the OpportunityLineItem. So, before adding a decision element, I figured I would test first and see what it took to produce the Opportunity Line Items associated Product2 fields but I get stuck halfway through.
I created a flow beginning with a temporary assignment of a particular OpportunityID (this will be replaced by Process Builder pushing in the OpportuntiyID later) to a variable.
I then run a Fast Lookup on the OpportunityLineItem where the OpportunityID equals my OpportunityID variable above, assign the records to an sObject Collection Variable and specify only the Product2Id field.
Next, I Loop through the opportunity lines in the sObject Collection Variable above, assigning the records to the Loop Variable sObject Variable.
The LoopVariable.Product2Id is then added to a Collection Variable in an Assignment and I close the loop from the Assignment back to the Loop element.
It looks like this:
When adding a screen element off the Loop to display the Assignment Element’s Collection Variable, it produces the expected results – it gives me all of the Opportunity Line Items associated Product2.ID’s. I have been unable to take this any further.
Theoretically, I would take those Product2.ID’s and run a Fast Lookup against them, but a Fast Lookup needs a Variable or sObject Variable as the filter value and my Product2.ID’s are now in a Collection Variable.
I have tried all combinations of Loops, Assignments and Fast Lookups to return specific fields from the Product2 object for my Decision element to ultimately be based on but I hit a wall every turn. I am sure I am overlooking something simple here as if I can produce a set of record ID’s, there is bound to be a way to use those ID’s to feed in to another subprocess. I am happy to provide any additional information if needed.
Thanks in advance!