Copy a list and update linked table records

Hi all!

Got stuck trying to iterate through the related records in the DB. There should be a very simple solution, would appreciate an advice!

I am creating an app for Agile Retrospectives, and in my DB structure there are the following entities:

  • State (let’s say - current Sprint)
  • Factors that affect team performance in the State (let’s say requirements not well defined)
  • Impact of a given Factor on a given State (e.g. time waisted to clarify the requirements)

While creating a new State, I need to save the current State for the record, including the related Factors and their Impact. (In the next States some Factors may be deleted or rephrased, also their impact may be changed).

For that I am doing the following:
Step 1: Change the status of the current State to some value “Past” and add it to some list of the past States.
Step 2: Create a new Thing of a Type State. Assign to all the fields (apart from lists) of the new State the values of the current State.

Step 3: Copy the list of Factors of the current State.
Step 4: Assign the new list of Factors to the “List of Factors” field of the new State.

Step 5: Copy the list of Impacts where State = current State (Do a search for…)
Step 6: Change the “State” field of the new list of Impacts to the new State for the whole list (Result of Step 5 ← State = new State)

and at this point I don’t know how to update the Factor value of the Impacts … as I’d need to replace for each Impact in the list created at the Step 5 the old ID of a Factor with the corresponding new ID from the list from the step 3…

Even if I sort both lists the same way and rely on the order I still need to iterate through both lists and so far I did not find out how :frowning:

Solved using BDK Utilities: [New Plugin] Bdk Utilities