How to create a number of new entities based on a list

0
Hello, I believe I would need to create these via a MicroFlow but can't quick figure out how.  I have a model like and Orders / OrderDetail, but the OrderDetails entities would be created from another list of entities name ComponentList.  Think of an order that is like a kit of items. I have created a MicroFlow with a parameter of Order; a retrieve of the ComponentList; and a Loop that iterates  on ComponentList and for each Component, it creates a new OrderDetail as a child of that Order. What I am uncertain of is how to return a new Order and the new OrderDetails from this MicroFlow. What is the output from the MicroFlow. Thoughts?   Tom
asked
1 answers
0

Hi Tom,

  It sounds like the first action you need to take is to create a new Order object in your microflow.  Then retrieve the componentList as you are currently doing.  As you iterate through the component list, create a new OrderDetail object based on the component you are iterating over.  Don't forget to set the association between the OrderDetail and the Order in your loop.  When you are done, pass the newOrder back as the return object.  You can set the return object by right clicking on the red end event in your microflow.

  When creating a number of entities in a loop like this, the best practice would be to create a list of OrderDetails before the interator loop. Then in the loop create a new OrderDetails as before.  Add another action in the loop to change the list of OrderDetails and add your new OrderDetails object to the list.  At the end of the loop, commit that list.  This stops you from committing over and over again in your loop.

  From here, you could choose to pass the newOrder as the return object and use that to populate a page.

Does this get at what you are trying to do?

answered