I have a main form (Scheduler) and added a subform to it (Product_Subform).. I can create records to add an new appointment repeating every X weeks that matches an existing appointment... but I want to also duplicate the subform records in the new appointments that are being created.
Thanks,
Jason
- //get current appointment record
- myApptID = input.ID;
- //repeat appointments
- repeatInterval = input.Reoccurring_Appointment;
- if(len(repeatInterval) > 0)
- {
- //get substring
- repeatIntervalDuration = repeatInterval.subString(1,2).toLong() - 1;
- if(repeatIntervalDuration = 2)
- {
- repeatIntervalDuration = 11;
- }
- //loop
- //create number to loop thru
- loop_list = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
- for each index myIndex in loop_list
- {
- if(myIndex <= repeatIntervalDuration)
- {
- //calculate weeks
- daysToRepeat = (myIndex + 1) * 7;
- // insert into scheduler form *This is working* creates new records
- recordID = insert into Scheduler
- [
- Client=input.Client
- Appointment_Type=input.Appointment_Type
- Practitioner=input.Practitioner
- Practitioner_User_Filter=input.Practitioner_User_Filter
- Ending_On=input.Ending_On.addDay(daysToRepeat)
- Beginning_On=input.Beginning_On.addDay(daysToRepeat)
- Added_User=zoho.loginuser
- Map_URL=input.Map_URL
- Map_URL_Client=input.Map_URL_Client
- Full_Name=input.Full_Name
- Visit_Notes=input.Visit_Notes
- Email=input.Email
- Client_Email=input.Client_Email
- Entry=input.Entry
- Total_Amount=input.Total_Amount
- ];
- // trying to add charges for each subform item - *This is NOT working - it creates records but they are not related to the appointment above - when I look at the appointment on those new records they don' t have any services listed like the original appointment has..*
- myRecord = Scheduler[ID == myApptID];
- for each myField in myRecord.Services
- {
- insert into Product_SubForm
- [
- Added_User=zoho.loginuser
- SchedulerLink=recordID
- Product_Name=myField.Product_Name
- Product_Quantity=myField.Product_Quantity
- Product_Price=myField.Product_Price
- Product_Total=myField.Product_Total
- ]
- }
- }
- }
- }