User Tips: Adding Multiple Products (Package) to a Quote v2.0 (with Client Script)

User Tips: Adding Multiple Products (Package) to a Quote v2.0 (with Client Script)

This solution is an improvement on the original idea which used deluge. My solution was posted in the comments are: https://help.zoho.com/portal/en/community/topic/adding-multiple-products-package-to-a-quote

The updated version uses client script instead of deluge.

Hopefully this might help a few people. It helps our reps speed up the process of creating quotes and quoting accurately.

Details below:


Problem:

We run numerous manufacturer promotions with various bundled items and discounts. Reps struggle to remember all details, leading to incorrect discounts on quotes.


Solution

I created a custom module for Product Packages. For each promotion, we create a "Package" including all products, discounts, and start/end dates. A quote lookup field allows users to select a package, automatically adding the related products with accurate pricing and information.

When a user selects a package, a client script retrieves all related products and discounts, adding them to the quote. The lookup field is then reset for additional product entries.

Some fields on the package layout include:

  1. Promotion type
  2. Status
  3. Start / End dates for the promotion. 
  4. Pop-up message field if we want to show the rep a message when quoting the package

I also have a workflow that sets the package to “Expired” when the record expiration date hits. The lookup is filtered in the quotes module to only show “Active” packages.

In Action (with lookup field to the package module):



The Setup:
Create a custom module “Package Items”. Add the fields as below. 



Additional Info
1. I also use client script to hide the “Auto-Quote” field when in a standard view page
2. When I name a package, a deluge script runs to append the Package ID number which is an auto-number field.


The Code: 

  1. try {
    // List of funny loading messages
    var loadingMessages = [
    "Cranking up the quote machine...",
    "One sec... just stepped out for coffee.",
    "Hold tight! The hamsters are running the wheels.",
    "Almost there... giving it a little extra attention.",
    "Loading... probably faster than your internet speed.",
    "Please hold while we make magic happen.",
    "Just a moment... our servers are stretching their legs.",
    "Your patience is appreciated... and rewarded!",
    "Brewing up your quote right now...",
    "Give us a second... we're flexing our technical muscles.",
    "Our system is doing some yoga... stay calm!",
    "Loading... don't worry, it's not stuck!",
    "Fetching your data... hopefully with no detours!",
    "Keep calm and let us handle the rest.",
    "Processing... taking a coffee break, be right back!",
    "Stay tuned... greatness is loading.",
    "Our system is running... faster than a cheetah!",
    "Looks like you're going all in on this quote!",
    "Getting things ready... just need a moment.",
    "Hold on... we're aligning some stars for you.",
    "Please wait... we're feeding the server squirrels.",
    "One moment... your quote is coming fresh out of the oven.",
    "Loading... just making sure everything is perfect!",
    "Generating your quote... thanks for your patience!",
    "Almost there... your quote is worth the wait!"
    ];

    // Select a random message from the list
    var randomMessage = loadingMessages[Math.floor(Math.random() * loadingMessages.length)];

    // Log the entire value object to see its structure
    log("Full value object: " + JSON.stringify(value));

    // Ensure value.id is defined before proceeding
    if (!value || !value.id) {
    log("No product selected or value.id is undefined");
    return; // Exit the script quietly since no valid product was selected
    }

    // Show loader
    ZDK.Client.showLoader({ type: 'page', template: 'vertical-bar', message: randomMessage });

    // Extract the product ID and name from the value passed in
    var packageId = value.id;
    var packageName = value.name;
    log("Product ID: " + packageId);
    log("Package Name: " + packageName);

    // Get the subform field from Quotes module
    var quotedItemsSubform = ZDK.Page.getField("Quoted_Items");

    // Fetch product information for the package ID
    var packageDetails = ZDK.Apps.CRM.Auto_Quote_Packages.fetchById(packageId);


    var packageStatus = packageDetails.Status; // Active or Expired.
    var popUpMessage = packageDetails.Pop_Up_Message; // Check the package for any Pop-up message we want to show
    log("Package Details: " + JSON.stringify(packageDetails));
    log("Package Status: " + packageStatus);
    log("Pop-Up Message: " + popUpMessage);

    // Initialize array for existing line items.
    var existingLineItems = quotedItemsSubform.getValue() || [];
    log("Existing line items: " + JSON.stringify(existingLineItems));
    //
    // Only include rows with products. Excude any blank rows from the quote
    var filteredExistingLineItems = existingLineItems.filter(function(item) {
    return item.Product_Name && item.Product_Name.id;
    }).map(function(item) {
    return {
    id: item.Product_Name.id // Include only the item ID
    };
    });
    log("Filtered existing line items: " + JSON.stringify(filteredExistingLineItems));

    // Array to hold new line items we are adding
    var newLineItemArray = [];

    // Check if package is active and populate new line items
    if (packageStatus === "Active") {
    var packageItems = packageDetails.Package_Details;
    packageItems.forEach(function(item) {
    var productLineItem = {
    Product_Name: {
    id: item.Item_Code.id,
    name: `${item.Item_Code.name} (${item.Item_Name})`
    },
    Product_List_Price: item.Item_Price,
    Description: item.Item_Description,
    List_Price: item.Item_Price,
    Quantity: item.Item_Quantity ?? 1, // Default to 1 if Qty is null or undefined
    Discount: Math.abs(item.Item_Discount ?? 0) // Get the discount or default to 0 if null
    };
    log("New product line item: " + JSON.stringify(productLineItem));
    newLineItemArray.push(productLineItem);
    });
    } else {
    // Show error message if the package is not active
    // My layout to only show Active items but if you don't do that this solves it.
    ZDK.Client.showMessage('This package / promo is no longer active. Please contact the admin for details.', { type: 'error' });
    ZDK.Client.hideLoader();
    return; // Exit the script since the package is not active
    }

    // Combine existing line items with new line items
    var updatedLineItemArray = filteredExistingLineItems.concat(newLineItemArray);
    log("Updated line items array: " + JSON.stringify(updatedLineItemArray));

    // Add all updated items to the Quotes page
    quotedItemsSubform.setValue(updatedLineItemArray);

    // Reset the pick list field so user can re-use
    ZDK.Page.getField("Auto_Quote").setValue(null);

    // Hide loader
    ZDK.Client.hideLoader();

    log("Final updated line items: " + JSON.stringify(updatedLineItemArray));

    // Function to show confirmation and number of items added back to the user
    var showSuccessMessage = function() {
    ZDK.Client.showMessage(`${value.name} selected. ${newLineItemArray.length} items added successfully.`, { type: 'success' });
    };

    // Function to show popup message and then success message
    var showAlertAndSuccess = function(message, heading, buttonText) {
    ZDK.Client.showAlert(message, heading, buttonText);
    showSuccessMessage();
    };

    // Check for pop-up message and show alert if it exists
    if (popUpMessage) {
    showAlertAndSuccess(popUpMessage, "Important Information", "Got It!");
    } else {
    // No pop-up message, show the success message
    showSuccessMessage();
    }
    } catch (error) {
    // Log the error
    log('Error: ' + error.message);

    // Show error message
    ZDK.Client.showMessage('An error occurred while adding items. Please try again.', { type: 'error' });

    // Hide loader
    ZDK.Client.hideLoader();
    }


      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive 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




                            Zoho Writer Writer

                            Get Started. Write Away!

                            Writer is a powerful online word processor, designed for collaborative work.

                              Zoho CRM コンテンツ








                                ご検討中の方

                                  • Recent Topics

                                  • Mailboxes and Alias Email Addeases - Best Palestine’s and Advice:

                                    Mailboxes and Alias Email Addresses - Best Practices and Advice: what is the best practice for the efficient means to manage And sort, alias, email addresses and third-party after or even the Zoho app itself. I am currently using both Thunderbird and
                                  • Has anyone built a discussion forum with a Creator Portal?

                                    I have built a Creator app for organisations to apply for refurbished tools that are sent by a charity. The charity now wants recipient organisations to be able to connect with each other within a region or country, to share advice on maintaining the
                                  • Ability for Super Admin to Set Locale Information for Users in Zoho Recruit

                                    Dear Zoho Recruit Team, I hope you're doing well. We would like to request the ability for Super Admins to configure Locale Information (Country/Region, Date Format, and Time Format) for users in Zoho Recruit. Currently these settings are only configurable
                                  • Add a block or widget to Zoho Sites that allows users to create an interactive contact card with contact buttons (email, LinkedIn, website, etc)

                                    The proposed feature consists of a pre-designed, customizable block that displays a person's contact information (e.g., a speaker, sales representative, or independent professional) and offers quick access to: Email (icon with mailto: link) LinkedIn profile
                                  • Zoho Recruit > Email Templates

                                    Dear All Background: We are using Zoho Recruit for the 4 business units under our group of company it our posting our of Job it will be done via our internal recruiter. In the Email templates, i want to be able to insert the individual business unit,
                                  • Zoho Voice & Zoho Recruit/CRM

                                    Hello, I'd love to use Zoho Voice with Recruit and CRM but it would need something very important to me, that has been a game changer to my daily routine, like Calendly has been for scheduling interview. It's call transcription with AI. I'm using Noota
                                  • Change start time after starting the timer

                                    Hello Projects Community, an amazing feature would be to change the start time of a running timer. I know this from some other time tracking softwares. Any idea about this? Best wishes Niels
                                  • Sending possible. Receiving not possible.

                                    We are not receiving mail in our company email. Could you please solve this. It has been recurring and I want it to be resolved once and for all. Please help.
                                  • Problema para enviar y recibir correos

                                    Buenos días, mi cuenta de correo secretaria@construccmauro.com presenta problemas y no me permite ni me envía ni recibe correos, me sale este error.No fue posible enviar el mensaje; Motivo: 554 5.1.8 Correo electrónico bloqueado saliente.  Aprende más., Agradezco
                                  • Data access tasks like 'For each record' aren't supported for 'integration forms'.

                                    My code is not running because i get the error "Data access tasks like 'For each record' aren't supported for 'integration forms'." I have my integration setup with Zoho CRM + Zoho Creator, the form is visible and working on my zoho creator however in
                                  • Zoho Reports Not Grouping from Subforms

                                    I have created reports from a subform. We have a budget from a standard field, and the bills added to a subform. I've summarised the bills in a field. In edit mode, the bills are joined per supplier, which is what we want. But then it converts and separates/duplicates
                                  • Create Automation for the Field "Mark up by"

                                    Hello everyone, I'm importing expenses from Zoho Expense to Zoho Books. I want to auto-calculate the "Mark up by" field based on the custom field “Discount” I created before. The trigger of the workflow will be the creation of the expense itself. The
                                  • Free Webinar Alert! Before vs After: Proven ROI from Zoho CRM + Workplace Integration

                                    Hello Zoho Workplace Community! Before: Scattered tools, lost leads, fragmented communication. Are you ready to stop the constant back and forth between tools to manage leads, emails, and team communication? After: Connected tools, streamlined processes,
                                  • Zoho Forms to Zoho Sign Integration - Fields Missing

                                    If a Zoho Form has image fields, it seems these can't be transferred to a Zoho Sign template for digital signature. Is there any way of pre-filling Zoho Form images onto a Zoho Sign template? Many thanks.
                                  • Is zoho SMTP slow today?

                                    Hi guys, Since yesterday I'm facing a slow communication over SMTP while sending emails. I already tried to use tls and ssl but nothing changes. There is anyone else experiencing related issues? I didn't find any maintenance in progress. Tested another
                                  • Link project invoices to sales orders

                                    As a business owner and project manager I create estimates with my clients which then become sales orders. When billing for project work I want to invoice against the agreed sales order. I see that I can create invoices and link them to sales orders in
                                  • The Urgent Need for Native Brazilian Payment Integrations: PIX and Direct Bank Connections

                                    Hello Zoho Team, I am writing to emphasize a critical functionality gap for Zoho Books in the Brazilian market: the lack of modern, native payment gateway integrations. The current options are insufficient. The Mercado Pago integration, for instance,
                                  • How to Fetch Images from Related Modules in Zoho CRM Mail Merge Templates?

                                    Hi team , Hope this email finds you well. I have a requirement where I need to create mail merge templates within Zoho CRM in such a way that they fetch images from a record stored in a different module. The way it works is I have one module "A" which
                                  • Zoho Calendar (Refresh Rate)

                                    Why don't the calendars refresh more than every 12 hours? That is crazy. I cannot be the only user who wants to see this change? I see and understand that I can MANUALLY update them, but need them to auto refresh either (1) whenever there is a change
                                  • "In Zoho CRM, during the Blueprint transition to the QC stage, I want to make the 'Packing Proof' image field mandatory."

                                    @Dr Saurabh Joshi @Haiku Technical Support @Ishwarya SG @Sparrow Hill President @Hugh Marshall "In Zoho CRM, during the Blueprint transition to the QC stage, I want to make the 'Packing Proof' image field mandatory."
                                  • Flow Error

                                    Hi Zoho Team, Any idea on this? This happens recently. Zoho Desk says "You are not authorized to access this resource."
                                  • Zoho Books/Square integration, using 2 Square 'locations' with new Books 'locations'?

                                    Hello! I saw some old threads about this but wasn't sure if there were any updates. Is there a way to integrate the Square locations feature with the Books locations feature? As in, transactions from separate Books locations go to separate Square locations
                                  • Books/Square integration with multiple bank accounts

                                    Hello, I need some workaround ideas! We have two parts of our business which have their own bank accounts and customers. We use 'locations' in Square to allocate the payments to the correct place and we use 'branches' in Zoho Books to define which transactions
                                  • Intergrating multi location Square account with Zoho Books

                                    Hi, I have one Square account but has multiple locations. I would like to integrate that account and show aggregated sales in zoho books. How can I do that? thanks.
                                  • [Webinar] Deluge Learning Series - Deluge Learning Series Built-in Functions in Deluge

                                    We’re excited to welcome you to the next session in our Deluge Learning Series – Built-in Functions in Deluge – Part 1. In this focused 1-hour live session, we will explore the practical use of built-in functions in Deluge scripting, with a spotlight
                                  • Zoho Hilfe in NRW für Kundenprojekt gesucht!

                                    Hallo, wir sind auf der Suche für ein Kundenprojekt, wer die Implementierung von Zoho übernehmen kann. Unsere Stärke liegt im Onlinemarketing, bzw. der Automatisierung mit Klick-Tipp und den Tools drum herum. In dem Projekt können wir dem Kunden mit dem jetzigen CRM nicht weiter helfen, bzw. ihn nicht auf die nächste Stufe bringen. Leider komme ich mit meiner Suche in Foren, SocialMedia und sonst wo nicht weiter.  Der Idealfall ist ein gemeinsamer Besuch vor Ort beim Kunden und hier eine Präsentation
                                  • Gaps in Core HR Functionalities in Zoho People

                                    Hello People team, We've been using Zoho People for quite some time now and truly appreciate its flexibility and customizability. That said, I wanted to share some feedback based on our experience implementing core HR processes within the platform. Several
                                  • Product and Service

                                    Hi guys, there is a difference between layout of product and service if Long Description field have some kind of text. Please see screenshot 1 for Service here: https://prnt.sc/7xWwPKd29nWP for Product here: https://prnt.sc/LGmtVd_U6H7q As you can see
                                  • Anyone Building AI-Based SEO Dashboards in Zoho Analytics?

                                    Hey everyone, I’m currently working on an SEO reporting dashboard in Zoho Analytics and looking to enhance it with AI-based insights—especially around AI visibility, keyword trends, and traffic sources. The goal is to track not just traditional metrics
                                  • Phone Number Integration

                                    I would like to be able to track my cell phone calls in the CRM.  So if a contact calls my cell phone number, a note of that phone call will be made in the CRM so that I don't have to remember to go back in and add the call manually. Is there a way to connect the CRM and my cell phone via a 3rd party? Such as Google Voice, Skype, etc. Its important that my clients don't have to call a new or different number and that sent calls use the same number as well. So if there is a way to connect my phone
                                  • Woocommerce Line Item Information

                                    I'd like to add each line item from a Woocommerce order to a zoho creator form record. The line items are found within the line items array, but I'm not sure how to get each item out of the array? Any help would be much appreciated.
                                  • Create Encrypted Zoho Forms URL for SMS Pre-Population forms using zfcrm_entity=

                                    Hello Zoho Forms Community and Zoho Team, I’m trying to send a Zoho Forms URL via SMS with pre-populated CRM contact data, inspired by a post from four years ago by GlennP (https://help.zoho.com/portal/en/community/topic/passing-the-crm). Our form is
                                  • Sales IQ - Bot Builder - Forward to Operator Action Card Improvement

                                    Hi team, It would be a great improvement to have an additional branch out of the Forward to Operator Action Card. I would like to allow 10 seconds for an operator to pick up the chat, if they don't or if they reject the chat I would like the Bot to continue
                                  • Important notice: Migration is needed from the legacy ASAP to the latest ASAP Zoho Desk flow

                                    We recommend upgrading to the latest version, as the older version will eventually be discontinued and will no longer receive any further enhancements or bug fixes. We are announcing an important update concerning the ASAP help widget in Zoho Desk. The
                                  • NFC Support

                                    Hi, I would like NFC Support like Zoho Creator, to pre-fill field values by scanning an RFID device. Zoho Creator NFC here: https://www.youtube.com/watch?v=F4JoMWnF82I Both on a Field's User Input (Mobile Apps), in additon to QR Code & Barcode today,
                                  • Live webinar: Building brand consistency using Zoho Show

                                    Getting people to remember your brand isn’t easy. And if your branding isn’t consistent, it becomes almost impossible. One place where consistency really matters? Presentations. Whether it’s a sales pitch, an event deck, or a team update, your slides
                                  • Getting an error "Not able to connect server. Verify your network connection" during proforma invoice converting to invoice.

                                    Getting an error "Not able to connect server. Verify your network connection" during proforma invoice converting to invoice. 
                                  • calendar I created in Zoho Creator not being imported to Google calendar any longer

                                    A calendar that I created in my Zoho Creator app is no longer updating (or showing up at all) in my google calendar. It used to export appointments I set up in my app to google calendar. I cannot figure out how to correct this.
                                  • Quoting Subscriptions with one Time costs

                                    Hello all, We sell a subscription SaaS service for which we provide one-time services for implementation and customization. Using CRM quotes i was able to create customized total fields to show the total one-time costs, monthly cost, total subscription
                                  • Automatisez efficacement avec le nouveau concepteur de workflows flexibles

                                    Auparavant, l'automatisation dans les modèles de fusion de Writer se limitait à des actions simples comme « fusionner et stocker », « fusionner et envoyer par e-mail » ou « fusionner et envoyer pour signature ». En revanche, il était jusqu’à présent impossible
                                  • Next Page