function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ian Campbell 16Ian Campbell 16 

Flow Help

Hello,

I have a Flow question that I hope is simple.

I am trying to design a Flow that will lookup records that meet a certain criteria then place the record IDs in a set of fields on another, already existing, record.

For example, if the lookup finds 3 records I want to then take the ID from record 1 and place it in field 1 on the other record, then take the ID from record 2 and place it in field 2, and take the ID from record 3 and place it in field 3.

I am able to lookup and find the records with no problem but I am not sure how to tell the Flow to loop through the records, grab the ID for each one, and then place the values in the fields in order.

If this is possible and anyone knows how to accomplish this I would appreciate the help.

Thanks!
Gaurav HandooGaurav Handoo
Hi Ian

Assuming that you need to place the record Id in the same object's record that you are already fetching in, for this you would need to do the following:
  1. Create two Record Type variable and allow multiple values in that
    1. One would be used for capturing records while lookup
    2. Second would be used for updating the records
  2. When you are doing a lookup of records, get all records that meet your criteria and feed them to the variable created above
  3. Add a loop element on this variable. Looping requires a record type variable with single value
  4. Within loop, use assignment element to assign the value. This would look like, <Loopvariable>.<FieldName> equals <Loopvariable>.Id
  5. Another assignment to add this loop variable to the second Record variable we had created above. This would look like <SecondRecordVariable> add <Loopvariable>
  6. Exit the loop
  7. Run an update element with the second record variable.
In case you are not looking to update the same record, you can still run through the above steps. However, the difference would be that you would be running two loops, one on the list of record whose Ids you want and other on the set of records that you want to update.Do ensure your matching criteria

In case you need further assistance, feel free to contact me at gaurav.handoo@gmail.com

Regards
Gaurav
Ian Campbell 16Ian Campbell 16
Hi Gaurav,

I appreciate your response.

I've tried your approach but, unfortunately it is not getting me the results I need.

When I use "add" in the Assignment it takes the IDs found in the collection and adds them together.

For example, if the collection holds ID 1234 and ID 4567 the "add" operator will place 1234567 into the variable.

What I need to happen is to take ID 1234 and place it in the first variable then take ID 4567 and place it in a second variable.

I need to be able to tell the Assignment to take the first result in the collection and place it in the first variable, the second in the second variable, and so on.

Hopefully this is possible.

Thanks!

Ian
Gaurav HandooGaurav Handoo
Hi Ian

Would it be possible to connect over a screenshare session sometime to sort this out. You can connect with me at gaurav.handoo@gmail.com

Regards
Gaurav