For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

Zoho Creator: Copy Subform to other Subforms

What?
A quick article on a snippet of code which copies one subform to other subforms in the same form.

Why?
I'm creating an appointment/booking system and I want the user to be able to set entries in a subform called "Mondays" then to click a button which copies it to the remaining working days.

How?
So I have a form with 6 subforms which list staff/employee shifts from Monday to Saturday. The form I have looks something like the following:
Zoho Creator: Copy Subform to other Subforms: Design
and displays as something like this:
Zoho Creator: Copy Subform to other Subforms: Form

The code
I create a workflow that when the decision box "Copy Monday to the Other Days" is clicked it runs the following deluge script:
copyraw
// only run if true
if(input.Copy_Monday_to_the_Other_Days)
{
    // init
    c_Tuesday = Collection();
    c_Wednesday = Collection();
    c_Thursday = Collection();
    c_Friday = Collection();
    c_Saturday = Collection();
    //
    // loop through Monday subform
    for each r_Row in input.Mondays
    {
        if(r_Row.In_Effect)
        {
            // get Monday entries/rows
            v_EventType = r_Row.Event_Type;
            v_EventStart = r_Row.Start_Time;
            v_EventEnd = r_Row.End_Time;
            //
            // create Tuesdays subform entries
            r_RowTu = Shifts.Tuesdays();
            r_RowTu.Event_Type = v_EventType;
            r_RowTu.Start_Time = v_EventStart;
            r_RowTu.End_Time = v_EventEnd;
            r_RowTu.In_Effect = true;
            c_Tuesday.insert(r_RowTu);
            //
            // create Wednesdays subform entries
            r_RowWe = Shifts.Wednesdays();
            r_RowWe.Event_Type = v_EventType;
            r_RowWe.Start_Time = v_EventStart;
            r_RowWe.End_Time = v_EventEnd;
            r_RowWe.In_Effect = true;
            c_Wednesday.insert(r_RowWe);
            //
            // create Thursdays subform entries
            r_RowTh = Shifts.Thursdays();
            r_RowTh.Event_Type = v_EventType;
            r_RowTh.Start_Time = v_EventStart;
            r_RowTh.End_Time = v_EventEnd;
            r_RowTh.In_Effect = true;
            c_Thursday.insert(r_RowTh);
            //
            // create Fridays subform entries
            r_RowFr = Shifts.Fridays();
            r_RowFr.Event_Type = v_EventType;
            r_RowFr.Start_Time = v_EventStart;
            r_RowFr.End_Time = v_EventEnd;
            r_RowFr.In_Effect = true;
            c_Friday.insert(r_RowFr);
            //
            // create Saturdays subform entries
            r_RowSa = Shifts.Saturdays();
            r_RowSa.Event_Type = v_EventType;
            r_RowSa.Start_Time = v_EventStart;
            r_RowSa.End_Time = v_EventEnd;
            r_RowSa.In_Effect = true;
            c_Saturday.insert(r_RowSa);
        }
    } 
    //
    // clear the other subforms of their entries
    input.Tuesdays.clear();
    input.Wednesdays.clear();
    input.Thursdays.clear();
    input.Fridays.clear();
    input.Saturdays.clear();
    //
    // populate the other subforms with our collections
    input.Tuesdays.insert(c_Tuesday);
    input.Wednesdays.insert(c_Wednesday);
    input.Thursdays.insert(c_Thursday);
    input.Fridays.insert(c_Friday);
    input.Saturdays.insert(c_Saturday);
    //
    // [OPTIONAL] Reset the decision box to false
    input.Copy_Monday_to_the_Other_Days = false;
}
  1.  // only run if true 
  2.  if(input.Copy_Monday_to_the_Other_Days) 
  3.  { 
  4.      // init 
  5.      c_Tuesday = Collection()
  6.      c_Wednesday = Collection()
  7.      c_Thursday = Collection()
  8.      c_Friday = Collection()
  9.      c_Saturday = Collection()
  10.      // 
  11.      // loop through Monday subform 
  12.      for each r_Row in input.Mondays 
  13.      { 
  14.          if(r_Row.In_Effect) 
  15.          { 
  16.              // get Monday entries/rows 
  17.              v_EventType = r_Row.Event_Type; 
  18.              v_EventStart = r_Row.Start_Time; 
  19.              v_EventEnd = r_Row.End_Time; 
  20.              // 
  21.              // create Tuesdays subform entries 
  22.              r_RowTu = Shifts.Tuesdays()
  23.              r_RowTu.Event_Type = v_EventType; 
  24.              r_RowTu.Start_Time = v_EventStart; 
  25.              r_RowTu.End_Time = v_EventEnd; 
  26.              r_RowTu.In_Effect = true
  27.              c_Tuesday.insert(r_RowTu)
  28.              // 
  29.              // create Wednesdays subform entries 
  30.              r_RowWe = Shifts.Wednesdays()
  31.              r_RowWe.Event_Type = v_EventType; 
  32.              r_RowWe.Start_Time = v_EventStart; 
  33.              r_RowWe.End_Time = v_EventEnd; 
  34.              r_RowWe.In_Effect = true
  35.              c_Wednesday.insert(r_RowWe)
  36.              // 
  37.              // create Thursdays subform entries 
  38.              r_RowTh = Shifts.Thursdays()
  39.              r_RowTh.Event_Type = v_EventType; 
  40.              r_RowTh.Start_Time = v_EventStart; 
  41.              r_RowTh.End_Time = v_EventEnd; 
  42.              r_RowTh.In_Effect = true
  43.              c_Thursday.insert(r_RowTh)
  44.              // 
  45.              // create Fridays subform entries 
  46.              r_RowFr = Shifts.Fridays()
  47.              r_RowFr.Event_Type = v_EventType; 
  48.              r_RowFr.Start_Time = v_EventStart; 
  49.              r_RowFr.End_Time = v_EventEnd; 
  50.              r_RowFr.In_Effect = true
  51.              c_Friday.insert(r_RowFr)
  52.              // 
  53.              // create Saturdays subform entries 
  54.              r_RowSa = Shifts.Saturdays()
  55.              r_RowSa.Event_Type = v_EventType; 
  56.              r_RowSa.Start_Time = v_EventStart; 
  57.              r_RowSa.End_Time = v_EventEnd; 
  58.              r_RowSa.In_Effect = true
  59.              c_Saturday.insert(r_RowSa)
  60.          } 
  61.      } 
  62.      // 
  63.      // clear the other subforms of their entries 
  64.      input.Tuesdays.clear()
  65.      input.Wednesdays.clear()
  66.      input.Thursdays.clear()
  67.      input.Fridays.clear()
  68.      input.Saturdays.clear()
  69.      // 
  70.      // populate the other subforms with our collections 
  71.      input.Tuesdays.insert(c_Tuesday)
  72.      input.Wednesdays.insert(c_Wednesday)
  73.      input.Thursdays.insert(c_Thursday)
  74.      input.Fridays.insert(c_Friday)
  75.      input.Saturdays.insert(c_Saturday)
  76.      // 
  77.      // [OPTIONAL] Reset the decision box to false 
  78.      input.Copy_Monday_to_the_Other_Days = false
  79.  } 

The Result
So now when I tick this decision box, I get something like the following:
Zoho Creator: Copy Subform to other Subforms: Result


Source(s):
  • Zoho Creator/Deluge: Insert rows in Subform
    Quick refresher:
    copyraw
    // declaring the row
    <row1> = <mainForm_linkName>.<subForm_linkName>();
    
    // assigning values for various subform fields in the row
    <row1>.<field_linkName> = <value>;
    <row1>.<field_linkName> = <value>;
    
    // declaring another row (declare as many rows as required)
    <row2> = <mainForm_linkName>.<subForm_linkName>();
    
    // assigning values for various subform fields in the row
    <row2>.<field_linkName> = <value>;
    <row2>.<field_linkName> = <value>;
    
    // declare a variable to hold the collection of rows
    <variable> = Collection();
    <variable>.insert( <row1>, <row2> );
    
    // insert the rows into the subform through the variable
    input.<subForm_linkName>.insert( <variable> );
    1.  // declaring the row 
    2.  <row1> = <mainForm_linkName>.<subForm_linkName>()
    3.   
    4.  // assigning values for various subform fields in the row 
    5.  <row1>.<field_linkName> = <value>
    6.  <row1>.<field_linkName> = <value>
    7.   
    8.  // declaring another row (declare as many rows as required) 
    9.  <row2> = <mainForm_linkName>.<subForm_linkName>()
    10.   
    11.  // assigning values for various subform fields in the row 
    12.  <row2>.<field_linkName> = <value>
    13.  <row2>.<field_linkName> = <value>
    14.   
    15.  // declare a variable to hold the collection of rows 
    16.  <variable> = Collection()
    17.  <variable>.insert( <row1>, <row2> )
    18.   
    19.  // insert the rows into the subform through the variable 
    20.  input.<subForm_linkName>.insert( <variable> )

Category: Zoho :: Article: 785

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.