How to copy objects from one entity to another?

I have this domain model: The owner of the application manages the TemplateProducts, these are the base version of my products. After I created a new customer a subset of these templates products should be added to the CustomizedProducts list of the customer. You then give the customer control over his CustomizedProducts. It should be the case that wen a customer changes his products this only happen to the products in his CustomizedProduct list. How can I copy the entities from the TemplateProducts to the CustomizedProduct list and make it work that this list applies to the specific customer only? It should be done by a microflow I think, but in which way? If possible provide an image or clear explanation of the steps. Thanks in advance.
1 answers

If it is just copying the objects why don't you create a microflow that does the following:

  1. retrieve all the templateproducts to copy
  2. loop over these templateproducts in a loop activity.
  3. per looped item create a new CustomizedProduct, and copy all attribute values
  4. also set the association CustomizedProduct_Customer to the customer that gets ownership
  5. make sure to add the new customizedproducts to a list that you then commit in a commit event outside of the loop.

That's it, if you don't want to manually copy all attributes you can use the copyAttributes function in the CommunityCommons appstore module.