You need to sign in to do that
Don't have an account?
HELP! Flow, loop, decision, create or update - Who can solve this puzzle?
I'm using a PB Flow and a Visual Flow to achieve the following. When a new Shipment (custom object) record is created, it contains Shipping Address details. If the address is X, and a Building Record (custom object) already exists also with a value X, then use the Visual Flow to relate those records. However, if X does not exist as a Building record, then create a new Building record, mapping over details from the Shipment, and then update the Shipment record to establish a relationship.
The flow below is not recognizing Buildings in the database and is instead creating new Buildings each time it runs. Can someone please advise on how to solve this puzzle?

These are my loop variables:

And these are the Decision Conditions I'm using to determine if there is a match between a Building in the Collection and the Variables passed through from the Shipment record (of couse this is not working).

The flow below is not recognizing Buildings in the database and is instead creating new Buildings each time it runs. Can someone please advise on how to solve this puzzle?
These are my loop variables:
And these are the Decision Conditions I'm using to determine if there is a match between a Building in the Collection and the Variables passed through from the Shipment record (of couse this is not working).
The problem here is that no matter whether there is a record with an identical address or not, but at the end of the loop, a new record will always be created.
A better approach will be to save the Id of record if found any identical record during looping, into a new variable. At the end of the loop, use a decision component for creating or relating a record. Like if there is any Id in the variable then relate that record and if the variable is NULL then create a new record.
All Answers
The problem here is that no matter whether there is a record with an identical address or not, but at the end of the loop, a new record will always be created.
A better approach will be to save the Id of record if found any identical record during looping, into a new variable. At the end of the loop, use a decision component for creating or relating a record. Like if there is any Id in the variable then relate that record and if the variable is NULL then create a new record.
Are you suggesting that I keep the Decision criteria as is, but change the Yes Outcome routing from an Update Records element to an Assignment element? In other words, if the Shipment record's shipping address matches that of a Building record, then assign the Building record's ID to a variable, and then after completing the loop go to a new Decision element - like this?
Yes, this is the same way as I was telling. Is this working?
Thanks
Not able to see the screenshot. There might be a problem with the variable being populated with the Building Id. Please check the variable while debugging the loop.
First, in the Decision Element I kept the criteria you had suggested, namely to determine whether or not var_Building_Id == NULL. However, as you can see I removed the loop altogether from this flow and instead used a Get Records element. This element is looking at the Building object and uses filter conditions that match shipping details against variables that were captured in the Shipment record that started this flow.
Here are the filter conditions I mentioned:
And here the Building variables, which I then use in the Decision element: