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

    Access your files securely from anywhere


            Zoho Developer Community




                                      Zoho Desk Resources

                                      • Desk Community Learning Series


                                      • Digest


                                      • Functions


                                      • Meetups


                                      • Kbase


                                      • Resources


                                      • Glossary


                                      • Desk Marketplace


                                      • MVP Corner


                                      • Word of the Day



                                          Zoho Marketing Automation


                                                  Manage your brands on social media



                                                        Zoho TeamInbox Resources

                                                          Zoho DataPrep Resources



                                                            Zoho CRM Plus Resources

                                                              Zoho Books Resources


                                                                Zoho Subscriptions Resources

                                                                  Zoho Projects Resources


                                                                    Zoho Sprints Resources


                                                                      Qntrl Resources


                                                                        Zoho Creator Resources



                                                                            Zoho CRM Resources

                                                                            • CRM Community Learning Series

                                                                              CRM Community Learning Series


                                                                            • Kaizen

                                                                              Kaizen

                                                                            • Functions

                                                                              Functions

                                                                            • Meetups

                                                                              Meetups

                                                                            • Kbase

                                                                              Kbase

                                                                            • Resources

                                                                              Resources

                                                                            • Digest

                                                                              Digest

                                                                            • CRM Marketplace

                                                                              CRM Marketplace

                                                                            • MVP Corner

                                                                              MVP Corner





                                                                                Design. Discuss. Deliver.

                                                                                Create visually engaging stories with Zoho Show.

                                                                                Get Started Now


                                                                                  Zoho Show Resources


                                                                                    Zoho Writer Writer

                                                                                    Get Started. Write Away!

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

                                                                                      Zoho CRM コンテンツ






                                                                                        Nederlandse Hulpbronnen


                                                                                            ご検討中の方





                                                                                                  • Recent Topics

                                                                                                  • Power of Automation :: Trigger Automatic reminders to the task owners five days before the due date.

                                                                                                    Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                                                                                  • Weekly Tips: Flags for an organized mailbox

                                                                                                    Wishing you all a Happy New Year 🎉 As we step into 2025, it's time to refocus and set our intentions for the year straight. Whether you're already back at work or just returning from the holidays, you probably have emails that need your immediate attention,
                                                                                                  • Cleanest way to change billing method after an invoice has been created?

                                                                                                    Hello, I've added a task with a different rate/hour to a project but cannot change the billing method. I get the following error method: An invoice has been created for this project. Hence, the billing method for the project cannot be changed. Do I have
                                                                                                  • Weekly Tips: Enhance Productivity with Quick Access

                                                                                                    Having thousands of emails, tasks, attachments, and reminders in a single inbox can make navigating to a specific option difficult, especially when you're in a hurry to get things done without putting in too much effort or thought. Whether you need to
                                                                                                  • Custom Fonts in Zoho CRM Template Builder

                                                                                                    Hi, I am currently creating a new template for our quotes using the Zoho CRM template builder. However, I noticed that there is no option to add custom fonts to the template builder. It would greatly enhance the flexibility and branding capabilities if
                                                                                                  • ZOho Vault access denied

                                                                                                    Hello Community, I have suddenly got restricted by accessing Zoho vault . How can I get access back ?
                                                                                                  • Language Field on Contact Person-level

                                                                                                    Dear at Zoho Books, would it be possible for you to have a Field for 'Language' for the Contact Persons under a Company. In CRM and Bigin we could create a Custom Field (Dropdown) for this effect but without any present in Zoho Books we could never sync
                                                                                                  • CRM - Copy data from Single Line to Lookup Field

                                                                                                    Hello, I need help to create a workflow with a custom function in order to copy value from a single value field to a Lookup Field. Module : Shipment Single value field API name : Customer_ID Lookup field API name : Account_ID WOuld be great to have some
                                                                                                  • Tasks are not visible or clickable anymore

                                                                                                    Hi, We're facing problems with tasks connected to a module. As you can see, if we open for example an account record, all open and closed tasks are not visible anymore (only text 'undefined') and we can not click on those tasks. Do you know what is
                                                                                                  • Payoneer for Zoho

                                                                                                    I have set up a gateway to my Zoho Books i.e. Payoneer for Zoho and connected it successfully with my Payoneer account. Then I created an invoice and sent it foward. But when my customer tries to make a payment, the error screen appears So what can I
                                                                                                  • What's New in Zoho Analytics Mobile BI App - January 2025

                                                                                                    Elevate your on-the-go analytics experience with the latest enhancements in the Zoho Analytics - Mobile BI App. These updates ensure a seamless, visually consistent, and feature-rich experience across mobile devices. Here’s what’s new: Enhanced Chart
                                                                                                  • Directly Edit, Filter, and Sort Subforms on the Details Page

                                                                                                    Hello everyone, As you know, subforms allow you to associate multiple line items with a single record, greatly enhancing your data organization. For example, a sales order subform neatly lists all products, their quantities, amounts, and other relevant
                                                                                                  • Zoho One Backup of entire account

                                                                                                    Hello, When using Zoho one is there a way to backup your entire account of all apps that you are using \ activively using in a single step or do you have to backup each applications data individually? Thanks,
                                                                                                  • Lookup field, odd issue

                                                                                                    So I tried creating and app that has the names of engineers so I can use that for a lookup in the other apps that are being created . I add the look up in a new app, launch the app and when I try to fill out the form its just blank in the drop down menu
                                                                                                  • Unable to send message;Reason:550 5.4.6 Unusual sending activity detected. Please try after sometime

                                                                                                    Hello i'm unable to send any email because i keep getting this error Unable to send message;Reason:550 5.4.6 Unusual sending activity detected. Please try after sometime i have literally sent less than 10 emails today i'm not sure why i'm getting this
                                                                                                  • Cannot unblock IMAP for my account

                                                                                                    IMAP got block on my account for suspicious activity because I was testing different VPN servers in different locations. When I try to unblock it I get an error that says Sorry , we are unable to process your request, please contact support@zohomail.com.
                                                                                                  • Zoho Team Inbox down for several hours

                                                                                                    Error while processing the request! javax.mail.MessagingException: java.io.IOException: Problem communicating with the recipient server
                                                                                                  • Migration meines Accounts auf einen europäischen Server

                                                                                                    Hallo, wie kann ich meine Daten auf einen europäischen Server migrieren lassen? Ich habe hauptsächlich mit Kunden in Deutschland zu tun, die einen entsprechenden Datenschutz erfordern. VG, Kai
                                                                                                  • Restrict Payment Methods

                                                                                                    Allow us to restrict certain payment methods specific for each customer.
                                                                                                  • CHange timeformat in Tasks from 12 to 24 notation. Is that possible?

                                                                                                    Hi, I'm in the middel of the proces to possible migrate from Office365 tot ZOho. There are still some questions. One of them: How can I change the timeformat from 12 hour to 24 hour format? I can change it in my calendar settings, but it doesn't change
                                                                                                  • Ability to use Rules to automatically "Exclude" transactions from Credit Card/Bank Statements

                                                                                                    Currently there is only the option to Categorize transactions based on rules, this request is to add "Exclude" to the rules so they could be automatically ignored based on the criteria.
                                                                                                  • Simplify Zoho API integration with Deluge’s invokeAPI task

                                                                                                    Hello all! Happy New Year! As we kick off 2025, we’re excited to share some of the latest updates to enhance your Deluge experience. While Deluge already offered robust API integration capabilities, we’ve taken it to the next level with the introduction
                                                                                                  • Support answers every 2 days

                                                                                                    I've tried to contact support via email, but they don't answer unless I call and complain. They still haven't solved my problem. Please reply.
                                                                                                  • How to authenticate my domain on ovh

                                                                                                    I don't succeed in adding an domain authentification on ovh. Should i first create a subdomain? But this doesn't work either, ti gi ves te same screen and the next button is greyed out when adding the info received from zoho
                                                                                                  • domain authentification on ovh and zoho

                                                                                                    I don't succeed in adding an domain authentification on ovh. Should i first create a subdomain? But this doesn't work either, ti gi ves te same screen and the next button is greyed out when adding the info received from zoho
                                                                                                  • How to Authenticate Heartland Footwear Email Domain

                                                                                                    Hi Zoho team! Can you give me a quick step(s) needed to Authenticate Heartland's email domain with Zoho? Thanks! :)
                                                                                                  • DKIM failed

                                                                                                    My zoho mail account couldn't be contacted.
                                                                                                  • Is there a list of Zoho Icons?

                                                                                                    Is there a list of Zoho Icons you can reference: i.e. business-gold is <image marginRight='7px' color='#2A70E7' bgColor='#FFFFFF' width='52px' height='52px' type='icon' value='business-gold' size='24px' cornerRadius='26px' iconType='solid' /> Thanks!
                                                                                                  • Unable to add organization consultants and contractors in Zoho People

                                                                                                    Hello Team: I am unable to add my few consultants and contractors in Zoho People. How to add these people as Users?
                                                                                                  • Bank Feeds Breaking Constantly

                                                                                                    Hey Everyone, I have already reached out to support about this issue but I am wondering if anyone else is having the same issue. My bank feeds keep breaking within days of me fixing them by updating the credentials. Its been happening for a while and
                                                                                                  • Custom module - change from autonumber to name

                                                                                                    I fear I know the answer to this already, but thought I'd ask the question. I created a custom module and instead of having a name as being the primary field, I changed it to an auto-number. I didn't realise that all searches would only show this reference.
                                                                                                  • Regarding Zoho flow trigger when zoho table record update

                                                                                                    So I'm setting up automation to sync between Zoho CRM and Tables using zoho flow now I setup trigger when I update record in zoho tables and test it and in payload I got object of ids like key is id of each colum and that's fine but main problem is I'm
                                                                                                  • Justworks

                                                                                                    We are in the process of moving from QB Online to Zoho Books. Our PEO service Justworks.com had an integrations with Quickbooks but, not Zoho Books which means we will have to manually enter payroll. Anyway to integrate?
                                                                                                  • Create custom rollup summary fields in Zoho CRM

                                                                                                    Hello everyone, In Zoho CRM, rollup summary fields have been essential tools for summarizing data across related records and enabling users to gain quick insights without having to jump across modules. Previously, only predefined summary functions were
                                                                                                  • How to apply customized Zoho Crm Home Page to all users?

                                                                                                    I have tried to study manuals and play with Zoho CRM but haven't found a way how to apply customized Zoho CRM Home Page as a (default) home page for other CRM users.. How that can be done, if possible? - kipi
                                                                                                  • Add option "Avoid custom home pages" to profiles

                                                                                                    We need our sales agents and members on each department in general to keep the same Home designed by their Managers. Let all users to create custom home pages is a huge mistake. The homepage creation must be limited by profile so only Managers are allowed to build the right home page for their subordinates.
                                                                                                  • Is it possible to set a value to a field based on certain conditions

                                                                                                    Greetings Say i have a field that i want to set its value based on the value of another field.. for example if "number" field has value greater than 10, i want to set my field's value to X. Or if radio group had option 1 selected, then i want to set my
                                                                                                  • Marketer's Space: Leveraging CRM Data for Dynamic Content and Personalized Campaigns

                                                                                                    Hello Marketers! Welcome back to another post in Marketer’s Space! We’re excited to continue our series on the many advantages of integrating Zoho CRM with Zoho Marketing Automation (ZMA). This series is designed to help you unlock the full potential
                                                                                                  • How can I understand in the search results which collection a note is in and how to immediately go to this collection?

                                                                                                    How can I understand in the search results which collection a note is in and how to immediately go to this collection? You can call the note properties window, but only the notepad is listed there. This is very inconvenient, especially when there are
                                                                                                  • restrict access to user to create invoice

                                                                                                    hi team we need to restrict particular users from accounts dept to create invoice directly from invoice module in zoho books . Rather , they can only able to create invoice is by using "convert to invoice" from "Sales Order" module . pls help us to solve
                                                                                                  • Next Page