Inserting Rows in subform

Inserting Rows in subform

Hi

Can anyone see what I am doing wrong in my code?

This is the the part of the form where the dates are selected




This is how it is converting to the subform records:




There should be 3 records under each date? But instead most of them are listed under the 23rd. I am guessing the error is somewhere in the red highlighted areas. My code is below:

//initialise collection
allRows = Collection();
for each dateSelected in input.Holiday_Clinic_Dates_Available
{
if(How_many_participants_would_you_like_to_book_in == 1)
{
// declaring the row
Row1 = Book_a_Holiday_Clinic.Holiday_Clinic_Daily_Bookings_Subform();
// assigning values for various subform fields in the row
Row1.Name=input.Name_child_1;
Row1.DOB=input.DOB_child_1;
Row1.Age=zoho.currentdate.getYear() - input.DOB_child_1.getYear();
Row1.Waiver="No";
Row1.Day=dateSelected;
Row1.Email=input.Email_child_1;
Row1.Phone_Number=input.Phone_Number_child_1;
Row1.Payment_Status="Success";
allRows.insert(Row1);
}
if(How_many_participants_would_you_like_to_book_in == 2)
{
// declaring the row
Row1 = Book_a_Holiday_Clinic.Holiday_Clinic_Daily_Bookings_Subform();
// assigning values for various subform fields in the row
Row1.Name=input.Name_child_1;
Row1.DOB=input.DOB_child_1;
Row1.Age=zoho.currentdate.getYear() - input.DOB_child_1.getYear();
Row1.Waiver="No";
Row1.Day=dateSelected;
Row1.Email=input.Email_child_1;
Row1.Phone_Number=input.Phone_Number_child_1;
Row1.Payment_Status="Success";
// declaring the row
Row2 = Book_a_Holiday_Clinic.Holiday_Clinic_Daily_Bookings_Subform();
// assigning values for various subform fields in the row
Row2.Name=input.Name_child_2;
Row2.DOB=input.DOB_child_2;
Row2.Age=zoho.currentdate.getYear() - input.DOB_child_2.getYear();
Row2.Waiver="No";
Row2.Day=dateSelected;
Row2.Email=input.Email_child_2;
Row2.Phone_Number=input.Phone_Number_child_2;
Row2.Payment_Status="Success";
allRows.insert(Row1,Row2);
}
if(How_many_participants_would_you_like_to_book_in == 3)
{
// declaring the row
Row1 = Book_a_Holiday_Clinic.Holiday_Clinic_Daily_Bookings_Subform();
// assigning values for various subform fields in the row
Row1.Name=input.Name_child_1;
Row1.DOB=input.DOB_child_1;
Row1.Age=zoho.currentdate.getYear() - input.DOB_child_1.getYear();
Row1.Waiver="No";
Row1.Day=dateSelected;
Row1.Email=input.Email_child_1;
Row1.Phone_Number=input.Phone_Number_child_1;
Row1.Payment_Status="Success";
// declaring the row
Row2 = Book_a_Holiday_Clinic.Holiday_Clinic_Daily_Bookings_Subform();
// assigning values for various subform fields in the row
Row2.Name=input.Name_child_2;
Row2.DOB=input.DOB_child_2;
Row2.Age=zoho.currentdate.getYear() - input.DOB_child_2.getYear();
Row2.Waiver="No";
Row2.Day=dateSelected;
Row2.Email=input.Email_child_2;
Row2.Phone_Number=input.Phone_Number_child_2;
Row2.Payment_Status="Success";
// declaring the row
Row3 = Book_a_Holiday_Clinic.Holiday_Clinic_Daily_Bookings_Subform();
// assigning values for various subform fields in the row
Row3.Name=input.Name_child_3;
Row3.DOB=input.DOB_child_3;
Row3.Age=zoho.currentdate.getYear() - input.DOB_child_3.getYear();
Row3.Waiver="No";
Row3.Day=dateSelected;
Row3.Email=input.Email_child_3;
Row3.Phone_Number=input.Phone_Number_child_3;
Row3.Payment_Status="Success";
allRows.insert(Row1,Row2,Row3);
}

      Zoho Developer Community








                              Zoho Desk Resources

                              • Desk Community Learning Series


                              • Digest


                              • Functions


                              • Meetups


                              • Kbase


                              • Resources


                              • Glossary


                              • Desk Marketplace


                              • MVP Corner


                              • Word of the Day



                                  Zoho Marketing Automation


                                          Manage your brands on social media



                                                Zoho TeamInbox Resources

                                                  Zoho DataPrep Resources



                                                    Zoho CRM Plus Resources

                                                      Zoho Books Resources


                                                        Zoho Subscriptions Resources

                                                          Zoho Projects Resources


                                                            Zoho Sprints Resources


                                                              Qntrl Resources


                                                                Zoho Creator Resources


                                                                  Zoho WorkDrive Resources



                                                                    Zoho Campaigns Resources


                                                                      Zoho CRM Resources

                                                                      • CRM Community Learning Series

                                                                        CRM Community Learning Series


                                                                      • Tips

                                                                        Tips

                                                                      • Functions

                                                                        Functions

                                                                      • Meetups

                                                                        Meetups

                                                                      • Kbase

                                                                        Kbase

                                                                      • Resources

                                                                        Resources

                                                                      • Digest

                                                                        Digest

                                                                      • CRM Marketplace

                                                                        CRM Marketplace

                                                                      • MVP Corner

                                                                        MVP Corner





                                                                          Design. Discuss. Deliver.

                                                                          Create visually engaging stories with Zoho Show.

                                                                          Get Started Now