Kaizen #99 - Render Widgets Using Client Script

Kaizen #99 - Render Widgets Using Client Script

Hello everyone!
Welcome back to another interesting post. In this post, let us see how you can render Widgets using Client Script.

Widgets are embeddable UI components that you can create and add to your Zoho CRM. You can use widgets to perform functions that utilize data from third-party applications. You can build widgets for Zoho CRM using our JS SDK.

You can render a Widget through Client Script and pass data from the Widget to the Client Script.

Use Case:
At Zylker, a manufacturing company, the Service Agent places orders using the Orders module.  There is a sub-form named Product list. The user should add the products by clicking the "Add row" button every time. 

Alert
Important Note : The aim of this post is to explain how to render widgets using Client Script. The use case considered can now be implemented using "Add multiple rows" button in the subform. For this, 'Add multiple rows simultaneously' option has to be enabled, in the subform properties. Click here for more details.

Notes



To avoid this, Zylker wants the users to select multiple products from a single pop-up. Once the user selects the products from that pop-up , the sub-form "Product list" should get updated with all those products(one product in one sub-form row).

Solution:

Whenever the user picks the Product Category, you can create a Client Script to render the widget. The Products selected by the user on the widget , will be passed to the Client Script and will be added as separate rows in  Product list subform.
 
1. Install Zoho CLI and add code to the app folder.
2. Upload the zip file as a Widget.
3. Create a Client Script to render the Widget and to add data to the Sub-form.


1.  Install Zoho CLI and add code to the app folder 

Follow the steps given in this post and add the html code, javascript file and css file.

Index.html



<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Choose products</title>
  <link href="styles/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
  <div class="wgt_cp_popupContent">
    <section class="wgt_cp_contentWrap">
      <div hidden="true" id="noProductDiv">
        <pre>No products associated to the selected deal</pre>
      </div>
      <table width="100%" cellspacing="0" id="pTable">
        <thead>
          <tr class="wgt_productTblHead">
            <th><input type="checkbox" id="selectAll"     onclick="selectAllProducts(this)"></th>
            <th>Product Name</th>
            <th>Product Category</th>
            <th>Unit Price</th>
            <th>Quantity in Stock</th>
          </tr>
        </thead>
        <tbody id="tbody"></tbody>
      </table>
    </section>
  </div>
  <script src="./script/script.js"></script>
</body>
</html>


Script.js

var count = 0;
var productData, maxRows = 0;
ZOHO.embeddedApp.on("PageLoad", async function (data) {
 console.log("data from Client Script", data);
 maxRows = data.max_rows;
 const search_response = await ZOHO.CRM.API.searchRecord({ Entity: "Products", Type: "criteria", Query: "(Product_Category:equals:" + data.product_category + ")" })
 if (search_response && search_response.data && search_response.data.length) {
  productData = search_response.data;
  var htmlString = "";
  productData.forEach(({ id, Product_Category, Product_Name, Unit_Price, Qty_in_Stock }) => {
   htmlString = htmlString.concat(
    `<tr>
     <td><input type='checkbox' onclick='selected(this)' id='${id}' class='products'></td>
     <td>${Product_Name}</td>
     <td>${Product_Category}</td>
     <td>${Unit_Price}</td>
     <td>${Qty_in_Stock}</td>
    </tr>`
   );
  });
  document.getElementById("tbody").innerHTML = htmlString;
 } else {
  document.getElementById("pTable").hidden = true;
  document.getElementById("noProductDiv").hidden = false;}
});
ZOHO.embeddedApp.init();
function selected(element) {
 element.checked ? count++ : count-- ;
 document.getElementById("selectedCount").innerHTML = `${count} Products selected`;
}
function closewidget() {
 if (count > maxRows) {
  alert("Selected product is greater than the maximum subform rows.");
 } else {
  var selected_products = [];
  for (product_element of document.getElementsByClassName('products')) {
   product_element.checked && selected_products.push(productData.find(product => product.id === product_element.id));}
  console.log("returning to Client Script ...", JSON.stringify(selected_products));
  $Client.close(selected_products);}
}


As per the above script, the products are fetched from the "Products" module based on the "Product Category" selected by the user. This information is captured in "search_response" and is added to the body of  widget.html. 
Here,  the code $Client.close(selected_products); will pass the selected products from Widget to the Client Script and close the widget rendered from Client Script. Click here for more details about the variable $Client.
Next step is to upload the zip file of the app folder.
Click here to view the complete code.

2. Upload the zip file as a Widget
  • Go to Setup > Developer Space > Widgets.
  • Click Create New Widget.

  • The Hosting should be "Zoho" and mention the html page of the app folder that you uploaded.
Note: The widget should be of "button" type in order to render through a Client Script.

3. Create a Client Script to render Widget and to add data to the subform
  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next.
  • The Client Script should render the Widget when the user selects Product Category. So Client Script should have field event on the field "Product Category".
  • On the Client Script IDE, you can see the below details.

  • Enter the following script in the Client Script IDE and click save.

var products_list = ZDK.Page.getField('Product_list').getValue();
if (products_list.length === 1) { // Clear subform if empty row
    !Object.values(products_list[0]).every(value => !!value) && products_list.pop();
}
// Open widget with product category & max. allowed rows based on existing subform data
var selected_products = ZDK.Client.openPopup({
    api_name: 'choose_products', type: 'widget', header: 'Choose Products', animation_type: 1, height: '570px', width: '1359px', left: '150px'
}, {
    product_category: value, max_rows: 25 - products_list.length
});
// Update subform with Selected Products from the widget Popup
if (selected_products.length) {
    selected_products.forEach(product => {
        products_list.push({ Product_Name: { id: product.id, name: product.Product_Name }, Quantity: 1, Unit_Price: product.Unit_Price });
    });
  ZDK.Page.getField('Product_list').setValue(products_list);
}


  • To render a widget from Client Script, use openPopup(config, data)  ZDK. You can specify the configuration details like api name of the widget, title, size, animation type as parameters and specify the data to be passed as 'PageLoad' event data in the Widget. 
  • The response from the widget (i.e user selection) is captured by the variable "selected_products". Then each product (id,name,product_name,quantity and unit_price) is pushed to the list products_list. Finally, the product list value  is updated to the Product Category sub-form using setValue(value) ZDK. 
  • Here is how the Widget gets rendered through Client Script.



We hope you found this post useful. We will meet you next week with another interesting topic! If you have any questions let us know in the comment section.

Click here for more details on Client Script in Zoho CRM.


As we approach the 100th post in our Kaizen series next week, we invite you to share your queries and concerns with us.  We are always looking for ways to improve our content and make it more relevant to our readers.

Please fill out this form to share your thoughts.




Happy Coding!




    Access your files securely from anywhere


                  Zoho FSM Video Tutorials


                        All-in-one knowledge management and training platform for your employees and customers.






                                              Zoho Developer Community




                                                                    • Desk Community Learning Series


                                                                    • Digest


                                                                    • Functions


                                                                    • Meetups


                                                                    • Kbase


                                                                    • Resources


                                                                    • Glossary


                                                                    • Desk Marketplace


                                                                    • MVP Corner


                                                                    • Word of the Day


                                                                    • Ask the Experts



                                                                              • Sticky Posts

                                                                              • Announcing the new SKILL.md for Zoho CRM and the updated OAS repository!

                                                                                We are introducing a new zoho-crm skill to make working with Zoho CRM Developer tools (like APIs, functions, widgets, client scripts, queries etc) easier and faster, with the help of AI in your preferred AI harness like Claude Code, Codex, Cursor, VSCode
                                                                              • Kaizen #261 : Using Zoho CRM Skill to generate complex COQL queries

                                                                                Hello everyone, In the previous Kaizen posts, we introduced the zoho-crm SKILL.md and discussed how it can help you when you are working with Zoho CRM APIs and Client Script. In this Kaizen, we will focus on using the Zoho CRM `SKILL.md` with GitHub Copilot
                                                                              • Kaizen #256 - Build an Arrival Readiness Web Tab in Zoho CRM

                                                                                Hi everyone! Welcome back to the Kaizen series! In the post, we discuss a use case in hospitality industry: how an Arrival Readiness web tab widget can be used to let reception staff identify and resolve issues before arrival of guests. Use case In the
                                                                              • Kaizen #198: Using Client Script for Custom Validation in Blueprint

                                                                                Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                                              • Kaizen #226: Using ZRC in Client Script

                                                                                Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this


                                                                              Manage your brands on social media



                                                                                    Zoho TeamInbox Resources



                                                                                        Zoho CRM Plus Resources

                                                                                          Zoho Books Resources


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

                                                                                                                Get Started. Write Away!

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

                                                                                                                  Zoho CRM コンテンツ


                                                                                                                    Nederlandse Hulpbronnen


                                                                                                                        ご検討中の方




                                                                                                                                  • Recent Topics

                                                                                                                                  • How to manage additional required address information for Customers and Vendors.

                                                                                                                                    Has anybody figured out a way to incorporate relevant delivery information in the limited address fields for customers and vendors? For example, most carriers have an additional 'delivery instructions' field to add important information like delivery
                                                                                                                                  • Action required: Authenticate your sender domain before December 14, 2026

                                                                                                                                    Starting December 14, 2026, Zoho Campaigns will enforce a daily sending cap for unauthenticated custom sender domains. If you're sending email campaigns from your own domain but haven't authenticated it yet, you'll only be able to send up to 5,000 emails
                                                                                                                                  • Change default "Sort by"

                                                                                                                                    Is there a way to change the default "sort by" when searching across modules?" in Zoho CRM? Currently the default sort method is "Modified time" but i would like to utilize the second option of "relevance" as the sort by default and not have to change
                                                                                                                                  • Enhanced access controls and smoother authentication for organization emails

                                                                                                                                    Available to customers in all DCs. Hello everyone, We've improved how organization emails work in Zoho CRM, which are used when multiple users need to send emails from a common address, like sales@company.com or support@company.com. Admins can set up
                                                                                                                                  • New Search Function

                                                                                                                                    Hey Team, The search function updated in our CRM about a week ago, so I assume it was an automated update across Zoho. It no longer displays leads/deals etc in Chronological order so that the most recently created or updated is the first to display which
                                                                                                                                  • Error AS101 when adding new email alias

                                                                                                                                    Hi, I am trying to add apple@(mydomain).com The error AS101 is shown while I try to add the alias.
                                                                                                                                  • Transaction rules for "Owner's Contribution" ?

                                                                                                                                    I have a bank account where a lot of the deposits are "Owner's Contributions" (i.e., the business owner investing money in the company). Is it possible to create a Transaction Rule to automatically recognize these? They all have the same verbiage from
                                                                                                                                  • Print a price list or price book

                                                                                                                                    Hi Community. Am I right in concluding that Zoho has no functionality to print a price list from either Zoho CRM, Zoho Inventory or Zoho Books? I won't get stuck on the fact that Zoho doesn't sync price books between Zoho CRM and Books/Inventory (more
                                                                                                                                  • The Social Wall: October 2026

                                                                                                                                    Hello everyone This month, we're making it easier to organize your monitoring workspace with Monitor Groups in Zoho Social. Organize your monitor columns into groups You can now organize your monitor columns into custom groups based on your preferences.
                                                                                                                                  • Field of Lookup - 5 Field Association Limit.

                                                                                                                                    This query relates to the post at: https://help.zoho.com/portal/en/community/topic/introducing-the-field-of-lookup-in-crm-public-early-access-2023 My simple (and common) scenario: I select an account / customer lookup and want their address pulled into
                                                                                                                                  • Feature Request - Electronic submission of tax returns in Canada

                                                                                                                                    Allow the user to submit Canada Revenue Agency GST/HST returns with NETFILE. Provide the same functionality for provincial revenue agencies for PST/RST remittances. Today Zoho Books only provides the math required to calculate each line, requiring the
                                                                                                                                  • Ability to translate Zoho CRM Kiosks

                                                                                                                                    Hi team, Is support for translating kiosk text and screen names in the Zoho CRM translation tool planned on the roadmap? Thanks,
                                                                                                                                  • Files in Teamspaces: keep your team's documents where the work happens

                                                                                                                                    Release Note: This feature is available for all accounts across all DCs Hello Everyone, A Teamspace is built around a specific team and a shared objective, and it holds the modules and projects that team works with every day. The document that team depends
                                                                                                                                  • How to download multiple files in Creator?

                                                                                                                                    I'm trying to download multiple files from a creator report using a for loop but it only seems to be downloading one file. It seems like no more code can be run after downloading this one file. Is there a way to download multiple files? I'm currently
                                                                                                                                  • Request for Zoho Desk Version and Module Details

                                                                                                                                    Kindly help us confirm the version of Zoho Desk currently being used in our portal, along with the module/edition name. We require this information urgently for our internal documentation.
                                                                                                                                  • ZohoMail_get_mail_attachment corrupts binary attachments (PDFs) over MCP

                                                                                                                                    Hi all, The Zoho Mail MCP tool ZohoMail_get_mail_attachment returns binary attachments as UTF-8 text, so PDFs come back corrupted and an AI client can't read or save them. What we see: - The response header is content-type: application/octet-stream;charset=UTF-8.
                                                                                                                                  • Request: Custom CSS Theme

                                                                                                                                    I would really like a custom CSS theme that enables me to completely customize the look and feel of the survey page based on the typography of my company brand. Unfortunately, there does not appear to be complete customization with existing themes. This
                                                                                                                                  • Découvrez le nouveau Zoho Analytics : l’analytique agentique pour toutes les entreprises

                                                                                                                                    Nous sommes ravis de vous annoncer le lancement du tout nouveau Zoho Analytics ! Cette nouvelle version marque un tournant majeur dans l’évolution de la plateforme. Initialement conçue comme une solution de BI en libre-service permettant de créer des
                                                                                                                                  • Zia Agents in Zoho CRM: a better way to set up digital employees

                                                                                                                                    Hello everyone, If you've been using Zia Agents in Zoho CRM, so far using Connections was the only deployment method you're familiar with. You create an agent in Zia Agents (define its objective, write instructions, use tools, add knowledge base) and
                                                                                                                                  • Keeping phone number text format exporting from Books to Sheet

                                                                                                                                    We have a custom function that copies data from our customers in Books to Sheets. In the process the customers' phone numbers (unless they contain a space) get treated as numeric values, so leading zeros get stripped off, and in some cases scientific
                                                                                                                                  • Admin Logging in as another User

                                                                                                                                    How can a Super Admin login as another user. For example, I have a sales rep that is having issues with their Accounts and I want to view their Zoho Account with out having to do a GTM and sharing screens. Latest Update (27th April 2026): With the early
                                                                                                                                  • Tool Parameter UI - Freeze Header

                                                                                                                                    When one has a number of tools with a number of parameters, scrolling down hides the heading information, forcing one to scroll back up to get confirmation which radio button is which: Seems like simply freezing the header would eliminate that issue.
                                                                                                                                  • Cannot replace custom tools

                                                                                                                                    This is so incredibly frustrating. Create a tool group. Add your custom schema to create your custom tools. Attach to an Agent. Now you need to update your schema to make an adjustment? You can't edit the schema or even re-upload a new schema. It blocks
                                                                                                                                  • Testing Tools - Can't View Response

                                                                                                                                    When adding a custom tool and trying to test it, one can see whether or not the test has a successful http response, but the actual payload cannot be viewed to verify the tool's performance. I thought that's what the little hover link was for, but mousing
                                                                                                                                  • more native app support for linux

                                                                                                                                    Dear zoho,pls build additional apps like zoho valt,zoho sheets,zoho show,zoho authenticator apps for linux ,because more and more people are increasing switching to linux this days,
                                                                                                                                  • Unbundle feature for composite items

                                                                                                                                    We receive composite items from our vendors and sell them either individually or create other composite items out of them. So, there is a lot of bundling and unbundling involved with our composite items. Previously, this feature was supported in form
                                                                                                                                  • Quick Reference Guide on join.zoho.com

                                                                                                                                    Joining a remote session can be difficult for the people who need it the most. Please add a quick reference guide and better documentation that my Grandma can read on the join.zoho.com site. It's not uncommon to spend 10minutes or longer in a session
                                                                                                                                  • Zoho Projects - Auto Populate Project on Project Invoices

                                                                                                                                    Hi Projects team, I noticed that when creating an invoice from a Project in Zoho Projects, the project is not selected on the invoice. Is this something which you would consider as a feature request? It seems silly that when you create an invoice from
                                                                                                                                  • Times prepopulating in Date/Time field on deal records

                                                                                                                                    Support tells me that there is no workaround to having the time auto-fill on a date/time field in our deal records -- that is HUGELY inconvenient and creates massive opportunity for error. Our deals involve several parts over various days/times, none
                                                                                                                                  • Email-Data Synchronization with Zoho Analytics

                                                                                                                                    Hello, Enterprise Support Community! We're excited to announce the availability of Email Data Synchronization with Zoho Analytics! This highly requested enhancement allows you to sync email data from Zoho CRM into Zoho Analytics, making it easier to analyze
                                                                                                                                  • Making shared forms available offline

                                                                                                                                    Hi, We used to be able to have our forms available offline even if it was a shared form. now we can't. Is this a new bug?
                                                                                                                                  • Zoho Forms API

                                                                                                                                    Is there any way to get all form entry list using API? Looking forward to hear from you
                                                                                                                                  • Documents greater than 40MB Preview

                                                                                                                                    hello, Documents bigger than 40 MB cannot be previewed in WorkDrive Web App or Mobile App. would it be resolved in future?
                                                                                                                                  • Calendar Booking - Related Deal

                                                                                                                                    Is it possible to automatically associate a Calendar Booking with an existing Deal in Zoho CRM? We're trying to use the native Calendar Booking feature. Our goal is to send a booking link to a customer from an existing Deal record, so that when the customer
                                                                                                                                  • Approval Process configuration is now more flexible and fully customizable

                                                                                                                                    Hello everyone! Approval Process is back with a better user experience that makes it easier to add rules to your processes. This enhancement includes some UI updates that help you create highly structured approval stages—and more. Let's look at the enhancements
                                                                                                                                  • Kaizen #268: Using Zoho MCP to Build and Configure Zoho CRM Cadences

                                                                                                                                    Hi everyone! Welcome back to the Kaizen series! In the previous Kaizen posts, Kaizen #265 and Kaizen #266, we explored how Zoho MCP can be used to work with Zoho CRM records, retrieve metadata, customize CRM, configure automation, and even coordinate
                                                                                                                                  • Deliverability Update: Impact of the Ongoing Microsoft 365 Service Disruption on Email Delivery

                                                                                                                                    Update (November 16, 2026): This incident is resolved. In its final update on November 14, Microsoft confirmed that all affected services have fully recovered and the backlog of email messages has been processed. Microsoft lists the end of impact as November
                                                                                                                                  • Zoho Inventory - Imporoved Order Fulfillment Reporting

                                                                                                                                    Hi Inventory Team, i've tried to contact you through support@eu.zohoinventory.com but haven't received a response. I am contacting you on behalf of a client. Our client is a car parts wholesale business and we set them up on Zoho Inventory earlier this
                                                                                                                                  • Say Hello to Telephony in Zoho FSM

                                                                                                                                    Zoho FSM now brings complete telephony support so your team can manage inbound and outbound calls without switching tabs. Faster responses, smarter routing, and total call visibility—all in one place. Choose the telephony setup that works for you Zoho’s
                                                                                                                                  • Increasing API Credits

                                                                                                                                    Hello everyone! Organizations consume Zoho CRM APIs for various business needs, and it's a show-stopper when you exhaust your API credits before the 24-hour rolling window replenishes your credits. To meet your growing needs and help you keep your business
                                                                                                                                  • Next Page