Hi;
This thread is a final part of the original thread started in the general section.
http://www.awareim.com/forum/viewtopic.php?f=1&t=8016
In here I'll give a summary and the BSV for those who are interested.
I had a challenge of creating objects (Sessions) in a loop and for each Session, I need an inner loop to create a series of Workout objects for the newly created Sessions. These newly created Sessions and Workouts were created from a previously read Sessions and Workouts. That created more challenge of maintaining Original and New instances in Context. I was able to do so, until the last iteration, where Mr. Tom Ford generously gave his time and efforts to resolve this. We tried to stay away from DUPLICATE action and use CREATE for full flexibility.
He actually re-did all the processes, which are much cleaner than mine, so I went back and re-did my app and works.
You will see 4 objects. Starting from the top of the hierarchy down to grandchild:
Customer
--Course
----Session
------Workout
Goal: I need a “Course” of a customer to be selected/Picked and the transfer program needs to:
1. Duplicate the Course under the same Customer.
2. Then Aware needs to Find all the “Sessions” of the original “Course” and create NEW Sessions. These New “Sessions” need to be reference to the New “Course” that was created. The New Sessions, belong to the New Course
3. Here comes the challenge – Aware needs to read Workouts of the Original Sessions and create new Workouts. But the Challenge is that, as each Session in Step 2 being created, I need to create these workouts, so I can reference the Workouts to the newly created Session as their parent.
This is where my problem starts to have step 3 as inner loop of Step2.
Attached, please find the BSV that Mr. Ford provided me. Enjoy!
Thank you Mr. Ford for your help!
Change the file extension from txt to bsv
FOR EACH within FOR EACH Loop
FOR EACH within FOR EACH Loop
- Attachments
-
- Loop_Within_Loop.zip
- (41.44 KiB) Downloaded 725 times