For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at http://ascentbusiness.co.uk/zoho-support-2.  For larger projects, check our bespoke pricing structure and receive dedicated support from our hands-on project consultants and developers at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at http://ascentbusiness.co.uk.

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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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 bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.