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.

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.
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!
Recent Topics
Systematic SPF alignment issues with Zoho subdomains
Analysis Period: August 19 - September 1, 2025 PROBLEM SUMMARY Multiple Zoho services are causing systematic SPF authentication failures in DMARC reports from major email providers (Google, Microsoft, Zoho). While emails are successfully delivered due
Accidentally deleted a meeting recording -- can it be recovered?
Hi, I accidentally deleted the recording for a meeting I had today. Is there a way I can recover it?
To Zoho customers and partners: how do you use Linked Workspaces?
Hello, I'm exploring how we can set up and use Linked Workspaces and would like to hear from customers and partners about your use cases and experience with them. I have a Zoho ticket open, because my workspace creation fails. In the meantime, how is
How to access email templates using Desk API?
Trying to send an email to the customer associated to the ticket for an after hours notification and can't find the API endpoint to grab the email template. Found an example stating it should be: "https://desk.zoho.com/api/v1/emailtemplates/" + templateID;
How to render either thumbnail_url or preview_url or preview_data_url
I get 401 Unauthorised when using these urls in the <img> tag src attribute. Guide me on how to use them!
Update Portal User Name using Deluge?
Hey everyone. I have a basic intake form that gathers some general information. Our team then has a consultation with the person. If the person wants to move forward, the team pushes a CRM button that adds the user to a creator portal. That process is
Zoho Bookings No Sync with Outlook
Zoho Bookings appointments are showing on my Outlook Calendar but Outlook events are not showing on Zoho Bookings. How do I fix this?
Unable to retrieve Contact_Name field contents using Web API in javascript function
Hello, I've added a field in the Purchase Order form to select and associate a Sales Order (Orden_de_venta, lookup field). I've also created a client script to complete some fields from the Sales Order (and the Quote), when the user specifies the related
Updating Woocommerce Variation Products Prices Via Zoho CRM
I can update product prices with this flow: But I can't update variant products. I got a code from Zoho for this, but I couldn't get it to work. It needs to find the product in the CRM from the SKU field and update the variation with the price there.
Emails Disappearing From Inbox
I am experiencing the unnerving problem of having some of the messages in my inbox just disappear. It seems to happen to messages that have been in there for longer than a certain amount of time (not sure how long exactly). They are usually messages that I have flagged and know I need to act on, but have not gotten around to doing so yet. I leave them in my inbox so I will see them and be reminded that I still need to do something about them, but at least twice now I have opened my inbox and found
Power of Automation :: Automatic removal of project users once the project status is changed.
A custom function is a software code that can be used to automate a process and this allows you to automate a notification, call a webhook, or perform logic immediately after a workflow rule is triggered. This feature helps to automate complex tasks and
Customizing Form Questions per Recipient Group in Zoho Campaigns/Forms
Hello everyone, I would like to ask if it’s possible in Zoho Campaigns or Zoho Forms to send out a campaign where the form questions can be customized based on the group of recipients. Use case example: I have prepared 20 questionnaire questions. For
Automatic category assignment
Hi, I’d like to ask if there is a way to automatically assign an expense category based on the recognized Merchant. What would be the simplest way to set up automatic category assignment? Alternatively, is there an option to first choose the category
Zoho Books - France
L’équipe de Zoho France reçoit régulièrement des questions sur la conformité de ses applications de finances (Zoho Books/ Zoho Invoice) pour le marché français. Voici quelques points pour clarifier la question : Zoho Books est un logiciel de comptabilité
Every time an event is updated, all participants receive an update email. How can I deactivate this?
Every time an event is updated in Zoho CRM (e.g. change description, link to Lead) every participant of this meeting gets an update email. Another customer noticed this problem years ago in the Japanese community: https://help.zoho.com/portal/ja/community/topic/any-time-an-event-is-updated-on-zohocrm-calendar-it-sends-multiple-invites-to-the-participants-how-do-i-stop-that-from-happening
Having Trouble Opening The Candidate Portal
Recently am having trouble opening the Candidate Portal. It keeps loading but cannot display any widgets. Tried Safari, Chrome and Edge. Non of them work. Please solve the problem ASAP.
Forms - Notification When Response Submitted
How do I set it up to generate an email notification when a response (class request) is submitted?
Notes Issues
Been having issues with Notes in the CRM. Yesterday it wasn't showing the notes, but it got resolved after a few minutes., Now I have been having a hard time saving notes the whole day. Notes can't be saved by the save button. it's grayed out or not grayed
How to disable user entry on Answer Bot in Zobot
Hi, I have an Answer Bot in my Zobot, here is the configuration: I only want the user to choose 1 of the 4 the options I have provided: When no answer found, user chooses 'I'll rephrase the question' or 'Ask a different question When answer is found,
More admin control over user profiles
It's important for our company, and I'm sure many others, to keep our users inline with our branding and professional appearance. It would be useful for administrators to have more control over profile aspects such as: Profile image User names Email signatures
Please Make Zoho CRM Cadences Flexible: Allow Inserting and Reordering Follow-Up Steps
Sales processes are not static. We test, learn, and adapt as customers respond differently than expected. Right now, Zoho Cadences do not support inserting a new step between existing follow-ups or changing the type of an existing primary step. If I realize
Changing the Default Search Criteria for Finding Duplicates
Hey everyone, is it possible to adjust the default search criteria for finding and merging duplicate records? Right now, CRM uses some (in my opinion nonsensical) fields as search criteria for duplicate records which do nothing except dilute the results.
Clear Tag & Linking Between Quotes and Sales Orders
Hi Zoho Team, In Zoho Books, when a quote is converted into a sales order, it would be extremely useful to have: A clear tag/indicator on the quote showing that it has been converted into a sales order. A direct link in the sales order back to the originating
Zoho Books Sandbox environment
Hello. Is there a free sandbox environment for the developers using Zoho Books API? I am working on the Zoho Books add-on and currently not ready to buy a premium service - maybe later when my add-on will start to bring money. Right now I just need a
Add Direct Ticket Link to Zoho Help Center Portal in Email Replies
Hi Zoho Support Team, We hope you're doing well. We’d like to request a small but valuable improvement to enhance the usability of the Zoho Help Center portal (https://help.zoho.com/portal/en/myarea). Currently, when someone from Zoho replies to a support
[Webinar] Deluge Learning Series - AI-Powered Automation using Zoho Deluge and Gemini
We’re excited to invite you to an exclusive 1-hour webinar where we’ll demonstrate how to bring the power of Google’s Gemini AI into your Zoho ecosystem using Deluge scripting. Whether you're looking to automate data extraction from PDFs or dynamically
Connecting Zoho Inventory to ShipStation
we are looking for someone to help connect via API shipStation with Zoho inventory. Any ideas? Thanks. Uri
Subform edits don't appear in parent record timeline?
Is it possible to have subform edits (like add row/delete row) appear in the Timeline for parent records? A user can edit a record, only edit the subform, and it doesn't appear in the timeline. Is there a workaround or way that we can show when a user
New in Cadences: Option to Resume or Restart follow-ups when re-enrolling records into a Cadence, and specify custom un-enrollment criteria
Managing follow-ups effectively involves understanding the appropriate timing for reaching out, as well as knowing when to take a break and resume later, or deciding if it's necessary to start the follow-up process anew. With two significant enhancements
Im Stuck in an EDIT ONLY WITH WIZARD issue
So I found Wizards to be a really helpful tool in minimizing the exposure of redundant, superfluous fields to staff that would never otherwise have to edit those fields. My issue is, that when the record (in this case a lead) is created with a wizard,
Account upgrade
Good evening, I upgraded my account and paid for it. From standard to professional. Unfortunately after the paiment my account was not upgraded. Please your advise. Best Regards Erik van Staverden
How to set ALL default dates of my organization to DD-MM-YYYY format?
All replies to this question comes from a time where the UI was different. It's extremely frustrating not being able to find how to do this simple setting change. I want everything and everyone in my organizations to have DD-MM-YYYY date format by default.
How can I sync from Zoho Projects into an existing Zoho Sprints project?
Hi I have managed to integrate Zoho Projects with Zoho Sprints and I can see that the integration works as a project was created in Zoho Sprints. But, what I would like to do is to sync into an existing Zoho Sprints project. Is there a way to make that
Can we generate APK and IOS app?
Dears, I want to know the availability to develop the app on zoho and after that .. generate the APK or IOS app and after that I added them to play store or IOS store.. Is it possible to do this .. I want not to use zoho app or let my customers use it. thanks
Zoho Subform Workflows onAdd of Row
Suppose I have a form with attached workflows onLoad. If I use the form as a subform, will it inherit the workflows or do I need to create new ones onAdd of row?
Session Expired
I constantly get "Session Expired" and need to relogin or close and open the application again. This gets really frustrating during the day. Is this something that can be solved? This really makes me want to leave the app as it is no go to need to reopen
Super Admin removal
I brought a sub, and I gave the Super admin rights to a person who is no longer with us, so I need to change, and I need to make myself the Super admin
Better Notes Commenting
Hi, I'd like to suggest better collaboration tools for NOTES. The current notes section for Accounts, Contacts and Deals is not ideally suitable for any degree of communication or collaboration. When responding to a note, there is no ability to leave
Exporting Templates
I have just spent 2 hours creating a project template for a Netsuite configuration, and want to share it with other Zoho Projects users - who have a different account. Is there any way to do this?
Power of Automation:: Streamline Associated Teams based on the Task Owner update.
Hello Everyone, A Custom function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:
Next Page