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

    • Create Project while winning potentials - Projects v3 api updated code

      Hi all, I've been using the built in function to create a project while a deal is closed won and noticed it had some missing fields when trying to reference the zoho projects v3 api documentation. Specifically the project group had some issues when adding
    • [Free Webinar] Zoho RPA - OCR, PDF Automation, & More

      Hello Everyone! Greetings from the Zoho RPA Training Team! We’re excited to invite you to our upcoming webinar on the latest release updates for Zoho RPA, where we’ll unveil powerful new capabilities designed to make your automation journey smarter, faster,
    • Merge feature parity with writer

      Hello Zoho team, I have run into a workflow limitation with Zoho Contracts and the lack of merge feature parity with what Writer can do. We have created a fairly complex merge process to create a statement of work based on several fields in our CRM which
    • Export option in Contacts is missing

      Hello - I've been clicking around Zoho all morning trying to find the export option. It formerly was in the right hand corner, above the search box, but now I don't see it. I've looked everywhere - Am I missing it somehow? I've attached a screenshot.
    • Formatting of cells changing by itself and formulas not always calculating automatically

      I'm new to Sheets and have been setting up a budgeting template that has many linked tabs. It's going fairly well except certain quirky things have been happening from time to time. 1- sometimes when I scroll up or down I lose formatting from a random
    • Unable to open iOS Zoho CRM app

      i am unable to open Zoho CRM iOS App in iPhone 14 Pro Max v18.5 and it is crashing immediately after i click to open
    • Whatsapp BOT with CRM

      Hello, how do you use Whatsapp integrations in zoho CRM?
    • sync two zoho crm

      Hello everyone. Is it possible to sync 2 zoho crm? what would be the easiest way? I am thinking of Flow. I have a Custom Module that I would like to share with my client. We both use zoho crm. Regards.
    • Side-by-Side view on Windows 11

      Is there a way to open two notes in a side-by-side view? I'm running Notebook on a Desktop running Windows 11. If this feature doesn't exist, do you have plans for it?
    • Value shows in balance sheet for Goods in Transit

      We have transferred goods from one warehouse to another warehouse and accepted the same at another warehouse. Although my balance sheet shows X amount as goods in transit value. I don't understand, how to clear that  Can anyone guide us please?
    • Resolution Time Report

      From data to decisions: A deep dive into ticketing system reports What are time-based reports? Time-based reports are valuable tools that help us understand how well things are going by breaking down key metrics over specific periods. By tracking, measuring,
    • Ask for a quote to multple vendors

      We are able to send a Purchase order, but How can we Send a quote request to our vendor, once the value changes every time? I didn't see any feature like this in Zoho Books/ Inventory. Send this request with the Items that we want to know the cost, to
    • Bigin merge field in email template for subject line to match lead name

      Hello We Are using email in to automatically create leads in our pipelines. When we want to reply from conversations, and apply an email template, it’s not matching the original subject line. It should be lead name to match. But it’s not working. Even
    • How to create auto-link between Invoice and Quote in CRM

      It's strange that when you 'convert' a quote into an invoice, it doesn't auto-link the two. How can we develop an auto sync so we don't need to manually link each invoice to their respective quote?
    • Why Are Columns Reset When Deleting Entry

      Hello, this is quite annoying. We use forms as a questionnaire for candidates, we filter entries by removing columns, when we delete an entry the columns reset. Every "delete" the columns reset, why!? Thank you
    • Pi or Pie? A slice of infinity in customer service

      Hey everyone! While Pi Day is on March 14 (3.14), July 22 marks another special occasion: Pi Approximation Day! On this day, we recognize the mathematical constant π (pi ≈ 22/7); a number that's infinite, irrational, and never-ending. Pi is essential
    • Configuración

      Hola acabo de instalar Zoho CRM y quiero configurarlo correctamente. Al respecto me surgen algunas dudas tales como la diferencia entre: Cuentas, posibles Clientes y Contactos. ¿Conceptualmente que son cada uno? ¿Como se se relacionan entre ellos? Si
    • Why Can't I add unicode emoji's to my signature?

      Why would Zoho Mail prevent me from adding unicode emojis to my email signature? Every time I try to save the signature, Zoho Mail erases the emoji and any nearby content. Every time I setup something with Zoho, I know I'm going to run into some incredibly
    • GL account associated to each supplier for new bill

      Hello I'm facing problem for all items of my bills that are not inventoried. The need is each time I enter new bill and after I select supplier the GL account section is autopopulated with default GL account (that I would like to add in supplier settings)
    • LinkedIn verification link and otp not receiving

      For the last 2 to 3 weeks I'm trying to verify my LinkedIn account to access my company's LinkedIn page, Linkedin is sending verification links and codes to this email address but I have not received any codes or links. Please help me here. Looking forward
    • Zoho reply to not working. just reply to my self

      Hello. i using on my wordpress website a contact form from Wsform. i can set the reply to email there. normally it works. but since i am using your wordpress plugin zoho mail it doesn`t work. its not using the reply to (email from customer). I just can
    • Mail Merge Stuck in Queue

      I am trying to send Mail Merge's and it never sends out to the full list. It always hits a portion and the rest remain in the "Queue" - the emails I am sending are time sensitive, so I need this to be resolved or have a way to push the emails through
    • SMTP Email Sending Not Working for My Domains and Apps

      Hello Zoho Support Team, I am experiencing a critical issue with sending emails via Zoho SMTP for my domain humanhup.com. Both of my applications, HumanHup and CheapUI, are unable to send emails using Zoho SMTP, even though the same setup was working
    • Receiving too many Spam Leads. Why?

      I am receiving so many junk leads from web forms created by zoho's platform. The junk queries are increasing day by day and are affecting our business. I am continuously following up with zoho team from the past one year but not getting any satisfactory
    • Why is Zoho supporting the Proud Boys?

      Hello. This is the only way I can find to contact your company. There is someone in Maine posing as a law enforcement officer, attempting to kidnap immigrants. They are also recruiting for a known hate group. They have an email address hosted by Zoho.com.
    • Composite Item - Associated/Component Items

      I am trying to find the Associated Item/Component Item field in the Composite Item Table in Analytics. Has anyone been able to find and utilize this field in Analytics?
    • What is a a valid JavaScript Domain URI when creating a client-based application using the Zoho API console?

      No idea what this is. Can't see what it is explained anywhere.
    • 🚀 WorkDrive 5.0: Evolving from a file sharing app to an intelligent content management platform: Phase 2

      Hello everyone, WorkDrive's primary focus has always been to provide an intelligent and secure content management platform, simplify collaboration, and be the central repository of files for all Zoho apps. In our previous announcement, we unveiled the
    • Use openUrl() to edit a specific record

      I am working on a queue app for my organization. I have a master queue that is a report of meetings with workflow buttons to manipulate the records. One of these buttons I would like to open the record and edit for the purpose of changing the queue lookup
    • why i cant access my web without the www

      please help me
    • Send Whatsapp with API including custom placeholders

      Is is possible to initiate a session on whatsapp IM channel with a template that includes params (placeholders) that are passed on the API call? This is very usefull to send a Utility message for a transactional notification including an order number
    • Help Centre Articles in Desk, Zia and iframe

      Hi, We embed SOP documents into articles from Scribe into using iframe. We are looking at zia indexing articles to present to agents to aid their work. Please advise if zia can view and learn from the content within the iframe?
    • Rich Text/WYSIWYG Input Area

      I'd like to have an option on ZoHo creator to create an input text area for HTML/rich text formatting. :)
    • How to create a directory report from one-to-many relationship

      Hi all, Newbie here. I'm converting an Access DB to Creator. I've learned Forms are tables and Reports are used to edit table rows, not Forms. I've got the data loaded and can maintain it with the Reports already done. I've done filtering and sorting,
    • Change Default Selection for Lookup field

      I have a Lookup field that I have locked, when I unlock it - the user can select the proper Zone but I need it locked, since this may change based on user selection of another field. Example. There are 3 potential zones. User A selects the Hospital Account
    • Restrict visibility and user permissions Creator 5

      I don't understand how restrict visibility for reports interacts with the already established role permissions. It seems that the default on restrict visibility has everything checked for all users, but I cannot set up different levels of permission for different individuals.  Right now I have three different ways to manage users and their access and it's confusing because everything has not migrated to Creator 5. Don't the role permissions extend to the reports as well? Are the selections under
    • LMS - Why do Trainers have to be Users?

      I'm not sure why the software is set up where trainers must be users (i.e., employees). This should really be changed, as there are many cases (the majority of cases for some companies) where classroom trainers are external or contractors. If this is
    • ZOho mail not stopped working with my domain.

      i have changed my name server settings in my domain sigmasquaretec.in . After that my emails are not working with ZOHO.
    • Request to Cancel Zoho Mail Subscription

      Hello Zoho Team, I have migrated to Google Workspace and would like to cancel my Zoho Mail subscription for my organization. Organization Name: AR Creators Media Admin Email: roman@arcreatorsmedia.com Subscription ID: RPUS2005901960812 Please cancel the
    • zoho smtp limit for free users

      What is Zoho SMTP limit for free users?
    • Next Page