How to set associations via micro flow?

0
I exported my data tables and a list of all the associations between both lists. I made a number of corrections in the association list and now I would like to upload this list back into the app.My current attempt is uploading the 2 columns in an temp entity and use a microflow to set the associations again. But that last part is not working. I have list with the associations in the micro flow, I loop through the list and use a change object to add the association for each record. Afterwards I commit everything.But this does not have any effect. Please advise what to do?
asked
1 answers
0

Hi Renzo,


Your approach is valid. The main thing to check is that you're changing the correct side of the association and that you're working with the actual persistent objects rather than only the temporary import objects.


For example, if your association is:

Parent 1 --- * Child


and your temporary entity contains:

ParentID | ChildID


the microflow could be:

Import Excel/CSV
      ↓
Temporary Association List
      ↓
Create empty Child List
      ↓
Loop through imported rows
      ↓
Retrieve Parent using ParentID
      ↓
Retrieve Child using ChildID
      ↓
Change Child
    Parent_Association = Parent
      ↓
Add Child to Child List
      ↓
End Loop
      ↓
Commit Child List


For a 1- association*, the reference is normally maintained on the many-side, so in this example I would change the Child object and set its Parent association.


Also, I would not commit each object inside the loop. For better performance and to avoid unnecessary database transactions, collect the changed objects in a list and commit the list once after the loop.


So instead of:

Loop
 → Change Object
 → Commit Object


use:

Create List
     ↓
Loop
 → Change Object
 → Add to List
     ↓
Commit List


If the association still isn't being created, I would check the association direction, whether the retrieved Parent/Child objects are actually found, and whether you're changing the persistent Child object rather than the temporary import object.


If you share the domain model showing the association and a screenshot of your Change Object activity, it should be possible to identify exactly where the issue is.


Kindly mark this as the accepted answer if it helps.

answered