Microflow how to create an object that has a reference

Hi All,   I am trying to create an entity that has a reference and can’t seem to be able to figure out how to do that.   The domain model is:   I need to copy records from CSV_EmployeeDep to Employee entity by using a microflow and also the association to Department entity.   Here is how the microflow looks like:   When I try to set the association, it fails as it needs to be a reference:   I tried something like this: to get the Department where [$IteratorCSV_EmployeeDep/DepName = Name], but still getting errors   How can I do this ?   Thank you
2 answers

Do the Departments already exist?
If so, retrieve the list of all departments (before the loop).

Inside the loop before creating the Employee add a List Operation and do a Find in the Deparment list. Member is Name and Equals is $iterator_EmployeeDep/DepName. This will return 1 object.

In the Create Employee, you will use this object as the association.


Make sure to create an EmployeeList before the loop. Add all created Employee records to the list and commit outside of the loop (best practice not to commit in the loop)


If the departments do not exist, it is more complex and I could write an instruction tomorrow..


Thank you Micha for the solution on this and for the tip on best practice


Here is how the microflow looks like: