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();
    }

    • Recent Topics

    • Assign values to hidden fields in native forms

      It would be great to be able to assign values (static or dynamic) to hidden fields in a form. Currently, I can only assign a value via the URL. I currently have a form integrated with a webhook, but I don't have a way to send useful form data as parameters,
    • Migrating Email Content to a Shared Mailbox Address

      I am moving my email to Zoho Mail (currently hosted through GoDaddy). I have created a user (me) and I have also created a "Shared Mailbox" Group (through the admin panel) with an email address I will be using as an organization address. My personal email
    • Calendly One-way sync- Beta Access

      Hello Community, Many of our Zoho Calendar users have expressed their interests in Zoho Calendar and Calendly integration. We've been tightly working on with Calendly team to provide a two-way sync between Calendly and Zoho Calendar. However, there have
    • Live webinar: Mastering financial presentations with Zoho Show

      Hey there finance professionals! We know many of you are currently knee-deep in report creation mode to wrap up the fiscal year for your organization. Creating a presentation to communicate essential financial data isn’t simple, with all the calculations,
    • Zoho Desk Android app update: Accessing the guided conversation bots in the IM module

      Hello everyone! In the latest version(v2.9.8) of the Zoho Desk Android app update, we have brought in support for Guided conversation bots within the IM Module. These bots use predefined conversation flows to automate initial responses, handle routine
    • Zoho Analytics Embed - Zoomed Right In?

      Hey all, I am using the Zoho Show app on an android TV and cannot figure out why, but the Zoho Analytics embed is zoomed right in. When I preview on my laptop it looks fine, when I go in and edit the code, it looks zoomed? Then when it displays on the
    • Assistance with Image File Upload in Zoho Creator

      Hi , I'm building an application for storyboard creation using Zoho Creator, integrating Gemini AI for automated image generation. In the "Generate Frame" form, user inputs are collected to construct image prompts. Current Workflow: On Validation (Form
    • Migrating all email accounts from cpanel shared hosting and email boxes to zoho

      I have already read previous articles posted on this forum but none of them suit my needs.So i am currently working for a small company. The company website runs on cPanel shared hosting and the company page is a WordPress website. I recently redesigned
    • Domain Change from apkbark.com to apkbark.io – Do I Need to Setup Zoho Mail Again?

      I recently migrated my website from the old domain https://apkbark.com to the new domain https://apkbark.io. The Zoho Mail setup was previously configured and working perfectly on the old domain. Now I would like to know: Will my Zoho Mail setup automatically
    • How to add different type of revenue under sales ?

      How to add different type of revenue under sales ?
    • Types of Revenue

      i have different types of revenue , I want to see under sales in different categories , while preparing invoice I want to allocated if possible
    • Zoho books account recovery

      I had submitted a request to restore zohobooks account, but I am yet to get a feedback till now. The email addresses used to access the zohobooks can not access it again. I don't know what went wrong. I need quick attention to this. More details are provided
    • Payments calendar for receivables and liabilities by due dates

      Hello guys! What method can you recommend for tracking and planning future payments against expected income? We operate on the principle - we expect some income this month, then we look at what expenses are due this month and pay accordingly. I've seen
    • Email Search

      Has search stopped working for people? Searched on Zoho email content, I get nothing back. Signed out and back in, still same issues
    • Zoholics Europe 2025: Your Ultimate Data Analysis (Zoho Analytics) Workshop Experience

      Why should you attend? This year, Zoholics Europe 2025 is putting data analysis centre stage. With a dedicated workshop designed to answer all your data-related questions, you’ll gain practical skills, real-time solutions, and expert insights that you
    • how i can update client_secret or refresh_token in case if my was stolen?

      i want to know how i can protect my data on this case
    • [Webinar] CoCreator – Generative AI-Assisted Application Development in Zoho Creator

      Hello Creators! The Zoho Developer Community is hosting a webinar on CoCreator – Generative AI-Assisted Application Development to showcase our latest AI capabilities. What's this about? It's all about our latest AI capabilities in Zoho Creator. Instead
    • custom fields not populating from deluge script into invoice

      Hello, I've created some Deluge script that is meant to take a few inputted invoice custom fields and calculate a few others. I can see when I execute the function that my inputted custom fields are being passed, yet im still ending up with all "null"
    • Using English But Dropdowns in Thai

      We have selected English in Settings but all of the dropdown boxes are in Thai. How do i change this? The organization is based in Thailand and we are using the THB as our currency, but need the dropdowns to be in English. Please help! 🙏
    • Introducing Import Contract API

      We are excited to introduce the Import Contract API in Zoho Contracts. Here's a brief overview: Import Contract API The Import Contract API allows you to import contracts directly into Zoho Contracts in any of the following states: Draft Signed Active
    • Cambio de Plane

      Tenia un plan gratuito, hice una actualización a un plan de pago, salí por completo y entre nuevamente, pero no me deja corregir, pagar o modificar las facturas que había realizado en el modo de prueba. Me da el siguiente error: Factura de proveedor se
    • Better integration between Zoho CRM and Zoho Bookings

      I've noticed that when a meeting which was created in Zoho Bookings is updated by a sales person in Zoho CRM, the change is not reflected back into Zoho Bookings. I have raised this with support who advised that meetings created in Bookings need to be
    • Why is there a limit to JSONString of less 100 characters

      having this problem.
    • Enhanced crash reporting in Zoho Apptics

      All app crashes have the same sad ending: The app dies while the user still wants to use it. But the reason behind each crash? They vary every time. Identifying the root cause and fixing it is already hard work for your dev team. What makes it harder?
    • Description column in the "all expenses" overview page?

      Hi! I'm new to Zoho Books and accounting. I'm surprised there doesn't seem to have a proper "description" field for the expenses, only "notes", and that I can't have such a description visible on the overview page. So that I can quickly visualize my expenses...
    • Only Default Administrator Profile can Convert Estimates Zoho Finance

      In Zoho Finance Only the Default Administrator Profile can convert the Estimates A different Profile with the Admin level permission cannot convert the Estimate of someone else to a Sales Order, Only and only the default Administrator Profile Why is that
    • Zoho Notebook suddenly running very slow on long notes

      I have been a longtime user of Zoho Notebook. Historically, it has run quite well, but I've noticed over the last few days that it has begun to run unbearably slow when typing in large notes, to the point where I can type four words and have to wait for
    • Is there a way to pass the source of the chat from SalesIQ to the CRM lead creation?

      Currently when I update the values of the visitor and the lead is automatically generated in the CRM it says that the lead source is Chat, but in reality it was from either Facebook, Instagram or WhatsApp. Is there a way to make sure that the correct
    • Imported tasks

      Good afternoon, I have recently setup a test instance of Zoho CRM and am currently working through a data migration from Hubspot usine the API migration tool. I needed to get a feel for how seamless this process was but I am running into an issue. It
    • Assigning Leads to Queues

      Do you support Queues as Lead Owner? This is a basic function in any CRM. Assign Lead to a Queue group where any member can take ownership by him self.
    • Migration of emails from Yandex to Zoho

      I am trying to migrate an yandex mail account to zoho mail account. I am confused with all the related articles/informations in the net. Could someone please outline the process to do it, just thinking about me as a novice with limited knowledge or experience. A couple of questions from the knowledge gained. 1. I believe we have to delete the yandex current MX from the website records and add Zoho MX. What happens to the emails as we remove the mail exchange record. Yandex stops updating emails and
    • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

      Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
    • Zoho Sheets working offline

      Hi, I am looking for the ability to work offline in Zoho Sheets, but currently I cannot find the process to complete this. Does someone have any ideas or steps I might have missed? Also does Zoho Sheets have the "Format as Tables" function as is currently
    • Fetching whole month availability via API

      We are currently building a custom calendar component that books directly into our client's Zoho Bookings instance. The challenge we are facing is that your API only allows fetching availability one day at a time, which is problematic. Our second workaround
    • reCAPTCHA

      Is the Bookings form protected by reCAPTCHA, or some mechanism to ensure submission of the appointment request form is made by a human vs. bot?
    • Recent enhancements to Bigin's workflows and Associated Products

      Greetings, I hope all of you are doing well! We're happy to announce a few recent enhancements we've made to Bigin. Let's go over each one in detail. Enhancement to workflows Trigger workflows when specific fields are modified to specific values Previously,
    • Zoho Survey Goes to Junk Folder

      Hello, My company is wanting to use Zoho Survey to send out a customer satisfaction survey, and we were wondering if Zoho Campaigns allows the emails to not go into their junk folder. We sent out a test email campaign to our team and for some people it went to their inbox and for others it went to their junk folder. Is there a way to eliminate this from happening? Hope to hear from you soon! Thanks!
    • Nifty enhancements to Reports in Zoho CRM

      Dear Customers, We hope you’re well! We are here with a line of useful enhancements to Reports in Zoho CRM that are readily available to access. Include or exclude Record ID in the report export Display currency fields in record currency Capture report
    • need a formula to return value as shown (zoho sheet)

      Dear folks, What should be the formula in cell B3 to get that output, based on input sheet data.
    • need a formula to return value as shown (zoho sheet)

      Hello folks, what should be the formula in B3, to get the value shown based on input sheet ranges. thanks in advance.
    • Next Page