Zoho Creator: Button on Report for Merging Multiple Selected Records

The aim of this article is to document how you can display a Creator report to the user, that they can select (tickbox) multiple records in that report, and then have a button that loops through all the selected (ticked) records. The example below documents a report of Quotes where we want to merge all the product line items of each quote into one single quote.
Zoho Creator - Report Multiple Records Selected
I've written this article because I keep forgetting on how to do this. I have a specific order of steps on how I do this, you may find other ways but this is one that works for me.

So here's an overview and then we'll go into more detail:
  1. Create a function that accepts a form of records
  2. Create a workflow that understands the function parameters

Create a function
Why are we doing this first? Well when I create a workflow, it will ask me to run a function, the Creator workflow process will then read what datatype of a parameter I'm sending to the function.

  1. So in "Edit this application" > go to Workflow > Functions > New Function: give the function a name
  2. select "Deluge" as the language
  3. give it a Namespace (for this example I will leave this on "Default")
  4. and set the return type (again in this example, I will leave this as "void")
  5. for Arguments
    • Specify a parameter name of your choosing, in our example I am going to prefix it with "l_" (for list) and the plural of what kind of records I am sending as parameters (in this case "Quotes").
    • As the actual parameter value, select the form which is the singular of the records that you are sending (in my example here I have a form called "Partners Quote".
Zoho Creator - Creating a function with the Form passed as a parameter
Within your function you can use the following as a reference. In theory, you could loop through each submitted quote but I do a call at the beginning of each iteration of the loop to retrieve all the data in each record r_QuoteDetails = Partners_Quote[ID == r_Quote.ID];. In the example below, this is a merging process of each quote which only contains 1 line item and not a subform of line items. You could adapt the following to also loop through a subform found on each record but for this simple demonstration, we will assume that each record only has 1 item.
void emailMergedReceipts(Partners_Quote l_Quotes)
    v_ContactFname = "";
    v_ContactSname = "";
    v_SubTotal = 0.0;
    v_TotalVat = 0.0;
    v_Total = 0.0;
    v_Total_Tax_Factor = 0.2;
    for each  r_Quote in l_Quotes
        r_QuoteDetails = Partners_Quote[ID == r_Quote.ID];
        v_ContactFname = r_QuoteDetails.Contact_Name.first_name;
        v_ContactSname = r_QuoteDetails.Contact_Name.last_name;
        v_LineItem_Name = r_QuoteDetails.Product_Name;
        v_LineItem_Desc = r_QuoteDetails.Product_Description;
        v_LineItem_Price = r_QuoteDetails.Product_List_Price;
        v_LineItem_Quantity = r_QuoteDetails.Product_Quantity;
        v_LineItem_TaxAmount = r_QuoteDetails.Product_Tax_Amount;
        v_LineItemTotalExclVat = v_LineItem_Price * v_LineItem_Quantity;
        v_LineItemTotalVat = v_LineItemTotalExclVat * v_Total_Tax_Factor;
        v_LineItemTotal = v_LineItemTotalExclVat + v_LineItemTotalVat;
        v_SubTotal = v_SubTotal + v_LineItemTotalExclVat;
        v_TotalVat = v_TotalVat + v_LineItemTotalVat;
        v_Total = v_Total + v_LineItemTotal;
    // other actions you want to do after all quotes looped through
Save your function and click on "Done" to ensure it's all saved in the system.

Create the workflow
Now go to a the "Design" mode of the report that contains the forms you want to be able to merge (multiple selection) and click on the "Actions" tab then on the 'plus' icon under "For Multiple Records" to add a button. In our example, the report is called "Your Quote History" and it is a report on the form "Partners Quote":
Zoho Creator - Create a button on the report
Add new action item
  1. Name your action item
  2. Name the workflow
  3. Execute the action for Collection of record (this step is very important!)
And you should have something like the following:
Zoho Creator - Add an action for Multiple Records
Click through on "Add New Action":
Zoho Creator - Add New Action
Select "Deluge Script"
Zoho Creator - Action Type: Deluge Script
Select an event: Run a function:
Zoho Creator - Action Type: Deluge Script
And the next screen is why I created the function in advance:
  • Select the application (should be the name of your Creator application)
  • Select namespace (if following this example, it will be "Default")
  • Select function (note that only functions that can receive a list/form object are listed here)
  • The argument name should be disabled/read-only, and for field name, select the myForm[Form Object]. (in our example Partners_Quote[FORM OBJECT]):
Zoho Creator - Run the function created earlier, specify the FORM OBJECT as a the field parameter
"Save" that then click on "Done" to make sure it's all registered in the system. Then click on "Create" to add your button to the report action "For Multiple Records".

Amazing! You're all done! Go test it by going to the report, hover the mouse over each row and a tickbox will appear, tick a few and click on your newly made button (as per the first screenshot on this article).

Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate
© 2021 Joel Lipman .com. All Rights Reserved.