Kaizen#76 - Using ZDK CRM APIs in Client Script

Kaizen#76 - Using ZDK CRM APIs in Client Script

Welcome to another week of Kaizen! In this post, let us discuss about the ZDK CRM APIs in Client Script.

Client Script provides us the flexibility to use its collection of ZDK Client APIs and ZDK CRM APIs. The ZDK CRM APIs invoke the Zoho CRM APIs. 
Here is the documentation on the available list of ZDK CRM APIs. 

Note:
Every execution of a ZDK CRM API affects your API Credits, as it implicitly calls the Zoho CRM API.

Let us see a few sample Use Cases where ZDK CRM APIs are used.

Use Case: 

ABC is a hardware manufacturing company. Consider that you want to achieve the following using Client Script in Detail Page (Canvas) of a custom module named Orders.

  1. The field Status should be editable only for the profiles "Salesperson" and "Administrator" and should be read-only for all other profiles.
  2. When the field Status is changed to "Dispatched" , send an email to the customer saying "Your order has been dispatched" and display a message that the email is sent.
  3. Add a tag "Delivered" to an order when the order status is changed to "Delivered".

Solution using Client Script

In order to send email, add tag and get user details through Client Script, you need to use the appropriate ZDK from the list of ZDK CRM APIs.
 To accomplish this requirement, create two Client Scripts as follows.

  1. Client Script for Detail Page (Canvas) onLoad (for requirement - 1)
  2. Client Script for Detail Page (Canvas) onChange of field Status (for requirements 2 and 3)

1. Client script for Detail Page (Canvas) onLoad (for requirement - 1)

  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next.



Enter the following script and click Save.


var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);
log(user.profile.name);
  if (user.profile.name != "Salesperson")&&(user.profile.name != "Administrator") {
      ZDK.Page.getField("Status").setReadOnly(true);
  }



Using ZDK.Apps.CRM.Users.fetchById(), you will be able to fetch the details of  the current user. The current user ID is captured using the Client Script Constant $Crm.user.id. So the above script will make the field "Status" a read-only field for all profiles other than Salesperson and Administrator. This ZDK CRM API calls the Get Records API to get the user information.
Here is how the Client Script works for Salesperson Profile users.



Here is how the Client Script works for other Profile users.



2. Client script for Detail Page (Canvas) onChange of field Status (for requirements 2 and 3)

  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next.


  • Enter the following script and click Save.


var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);
var record = $Page.record_id;
// send email when the order status is "Dispatched"
if (value == "Dispatched") {
  var mail = new ZDK.Apps.CRM.__Actions.Models.Mail();
  mail.from = { "user_name": "ABC Industries", "email": "ABCIndustries@ABC.com" };
  mail.to = [{ "user_name": user.first_name + " " + user.last_name, "email": user.email }];
  mail.subject = "You order has been " + value;
  mail.content = "Hello" + " " + user.first_name + " " + user.last_name + ",   " + "We are glad to let you know that your order has been dispatched";
  mail.mail_format = "text";
  var response = ZDK.Apps.CRM.Orders.sendMail(mail, recordrecord);
ZDK.Client.showMessage("Sent mail to notify that the order dispatch is done.", { type: 'success' });
}
// Add tag when the order status is "Delivered"
if (value == "Delivered") {
  var Order = ZDK.Apps.CRM.Orders.fetchById(record);
  var response = Order.__addTags(["Delivered"]);
}


  • Here, sendMail(mail_object, record_id) is the ZDK CRM API that internally calls the Send Mail API and  __addTags(arrayOfTagNames) is the ZDK CRM API that internally calls the Add Tags to Records. To capture the current record id, $Page.record_id is used and to fetch the current user details, the constant $Crm.user is used.

  • Here is how the Client Script works.



  • When the status is updated as "delivered" the tag will be added as shown in the following image.


  • When the status is updated as "delivered" the tag will be added as shown in the following image.

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.

Cheers!


    Access your files securely from anywhere







                          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

                                                          • Kaizen #197: Frequently Asked Questions on GraphQL APIs

                                                            🎊 Nearing 200th Kaizen Post – We want to hear from you! 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 #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.
                                                          • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

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

                                                            🎊 Nearing 200th Kaizen Post – We want to hear from you! 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.
                                                          • Client Script | Update - Introducing Commands in Client Script!

                                                            Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands


                                                          Manage your brands on social media



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

                                                                                                          • Ship via Carrier Not Working Since Commerce Update

                                                                                                            Since the recent update to the Commerce platform, I can no longer use the ship via carrier function. It will take me to the address screen and let me verify them but when I go to save and move tot he next screen it will not do anything. This is happening
                                                                                                          • automations: Can I execute a step on a specific date?

                                                                                                            I have created a form in Zoho forms, and created a contacts list. I have also begun setting up an automation with the intention of sending the form to the contact list on a specific date every month (via email) for the entire year (essentially sending
                                                                                                          • Zoho Expense - The ability to add detail to a Trip during booking

                                                                                                            As an admin, I would like the ability to add more detail to the approved Trips. At present a requestor can add flights, accommodation details and suggest their preferences. It would be great if the exact details of the trip could be added either by the
                                                                                                          • Adding Folders in Android App

                                                                                                            Is it possible to create a new email folder within the Zoho Mail Android app?  Or can this only be done from the desktop version of Zoho Mail? Cheers!
                                                                                                          • Schedule Exports for Regular Project Updates

                                                                                                            Tracking project data often means exporting data at regular intervals. Instead of manually exporting data every time, users can schedule exports for Phases, Tasks, and Tasks in Zoho Projects. These exports can be set to run once, daily, weekly, or monthly
                                                                                                          • Question about custom fields using Pivot Tables.

                                                                                                            I have created a pivot table showing annual revenue of a client and how much payment that client is paying my company. Is there a way using pivot table to add an additional field that subtracts those to fields / shows me a percentage of that difference?
                                                                                                          • Request for Light/Dark Mode

                                                                                                            Would love the ability to switch between Light and Dark mode similar to Zoho CRM. https://help.zoho.com/portal/en/community/topic/introducing-dark-mode-light-mode-a-new-look-for-your-crm
                                                                                                          • Signature field is showing black

                                                                                                            Hello, When customer signed the service form, it is showing as below picture Phone model: iPhone 16 Pro We tried delete and install application, but it not solved. This has on phone of a few person. There is any advice to solve this?
                                                                                                          • Journey Email - Ignored Contacts

                                                                                                            I have a journey setup which simply sends a string of emails over time. For some reason I am getting large amounts of the contacts who enter the first email being ignored and I can't find anywhere in reports or audit logs why these contacts are not
                                                                                                          • Involved account types are not applicable when create journals

                                                                                                            { "journal_date": "2016-01-31", "reference_number": "20160131", "notes": "SimplePay Payroll", "line_items": [{ "account_id": "538624000000035003", "description": "Net Pay", "amount": 26690.09, "debit_or_credit": "credit" }, { "account_id": "538624000000000403", "description": "Gross", "amount": 32000, "debit_or_credit": "debit" }, { "account_id": "538624000000000427", "description": "CPP", "amount": 1295.64, "debit_or_credit": "debit" }, { "account_id": "538624000000000376", "description":
                                                                                                          • Zoho Books - Include Payment Terms as a Custom View filter

                                                                                                            It would be great if you could created a custom view based on Payment Terms. This would be really handy for seeing a list of customers who have credit terms. A workaround is not required. I could do something with a creditor checkbox, but it would be
                                                                                                          • How to update changed purchase account of item in invoice

                                                                                                            I have selected the wrong purchase account for various articles and created invoices. I had to adjust the purchase account in the article afterwards, but the old purchase account is still posted in the transaction-journal of the invoice. To adjust the
                                                                                                          • Help - Zoho CRM notification on mobile (IOS/Android)

                                                                                                            Hello Community! Can I get the IOS/Andoid CRM app to notify me of events, calls, etc. due as I can with MANY other apps?   I am running the free Zoho I would like this to be native to the Zoho CRM app. I do not want to write a sep. mobile app
                                                                                                          • Zoho Books Idea - Include another field in Bank Details for Address

                                                                                                            Hi Books team, Currently use the Description field in the Bank Details to store the bank's address. This works fine but it would be great if you could add another field for Bank Address, so that other notes about the bank account could be stored in the
                                                                                                          • a question about the COQL API v8

                                                                                                            When I specify eight or more values in a WHERE IN clause and execute it, an error occurs. Is there a limit to the number of values that can be specified in a WHERE IN clause? ↓Error select * FROM Vendors WHERE (id in (1, 2, 3, 4, 5, 6, 7, 8, 9)) ↓Success
                                                                                                          • Zoho Books Idea - Bank Details Button on Banking

                                                                                                            Hi Books team, Sometimes I'm asked to share bank details with a customer or a colleague. So I go to the Banking Module, find the correct bank account, click Setting > Edit, then copy and paste the bank details. Wouldn't it be great if there was a button
                                                                                                          • JS SDK 8.0 – TypeError: Cannot read properties of undefined (reading 'getCacheStore') with sample code

                                                                                                            Hello Zoho Support Team, I’m integrating the Zoho CRM JavaScript SDK v8.0 and I’m getting the error below when running your official sample. I tested directly from: https://github.com/zoho/zohocrm-javascript-sdk-8.0/blob/main/samples/create_records_sample/create_records.js
                                                                                                          • Function #55: Convert multiple quotes to single SO using Custom Button

                                                                                                            Hello everyone, and welcome back to our series! In Zoho Books, after a quote is accepted by your customer, it can be converted into a sales order or an invoice. Often, a customer might have multiple quotes, and for easier billing or upon the customer's
                                                                                                          • Time based workflow without edit/action

                                                                                                            Hello I need help solving this problem if possible. We have Deals come into the CRM via Live Transfer which have the field properties: Stage = New Channel = Inbound Some of them don't get answered so we want these to automatically go into our Outbound
                                                                                                          • What's New - August 2025 | Zoho Backstage

                                                                                                            Every month, Zoho Backstage grows with you. These updates aren't just features and fixes, they're about making your workday smoother, your events more impactful, and your attendees happier. We’ve listened, learned, and shaped this release to keep things
                                                                                                          • prevent selling expired items

                                                                                                            Hello. I need to make a constraint on expired batch items not to be sold. Is it possible in Zoho Inventory? if so, then how? Thanks for further help.
                                                                                                          • Product details removed during update from other system

                                                                                                            We maintain our product details in an other system. These details are synchronized with Zoho at the end of each day, through an API. This has worked perfectly sofar. But last Monday, all product codes and some other product data have been wiped during
                                                                                                          • Client Customer

                                                                                                            I purchased a customer user license, but we cannot see the project I added in the customer account. I would like to ask for support on what we should do.
                                                                                                          • Add Ability to Use Zoho Finance Tags

                                                                                                            For Zoho Finance (Books and Inventory), the current actions do not allow us to affect the tags associated with the entities in question (customers, vendors, items, etc.). Please consider adding this functionality into the actions.
                                                                                                          • Embeded Signing doesn't work on Safari Browser

                                                                                                            We have implemented Zoho Sign in our website by using embeded signing, It works perfectly on Chrome. But it fails on Safari, We get stuck on Zoho Sign Page during redirection from Zoho Sign to our website after signing the document, Please let us know
                                                                                                          • Dataprep Webhook Limits and Cannot update column with Dataprep

                                                                                                            I have two problems : 1 - I am using Airflow to trigger my pipeline, and when I tested it, it worked fine a couple of times. However, after that, I received an error: {"code":429,"message":"Request rate limited"}. I didn’t send too many requests — maybe
                                                                                                          • New in Zoho Forms: Google reCAPTCHA v3 for smarter spam protection

                                                                                                            Hello form builders, Spam submissions are one of the biggest challenges when you share your forms online. They not only clutter your data but can also waste valuable time. To help you combat this without making life harder for genuine respondents, we’re
                                                                                                          • Project Management Bulletin: August, 2025

                                                                                                            We’ve touched a grand 19 years since we started pioneering project management solutions with Zoho Projects. What started as a simple one-page interface is now a suite of products with Zoho BugTracker, Zoho Sprints, and our new debut Zoho Projects Plus,
                                                                                                          • Zoho Sign and Zoho Workdrive Integration

                                                                                                            Hello, there. I want to know if it's possible to save a signed document from Zoho Sign in an specific folder for each signer in Zoho Workdrive.  For example: If John Doe signs the document in Zoho Sign I want to save it automatically in a folder named
                                                                                                          • Empowered Custom Views: Cross-Module Criteria Now Supported in Zoho CRM

                                                                                                            Hello everyone, We’re excited to introduce cross-module criteria support in custom views! Custom views provide personalized perspectives on your data and that you can save for future use. You can share these views with all users or specific individuals
                                                                                                          • How do you list multiple contacts for a lead?

                                                                                                            My sales team wants to be able to add additional contacts for leads, how do we do that? Is there a different way we should be using the lead / contact functionality? Moderation update (9th September 2025): Our developers have built an extension to achieve
                                                                                                          • Modifying Three Dot Menu Options

                                                                                                            Is there a way to modify the three dot menu options that display in a Report header? They currently display: Show As (List, Calendar, Timeline), Print, Import, Export. I'd like to remove the Show As and Print options, since they aren't applicable for
                                                                                                          • Field Not Updating in FSM Script - Service and Parts module.

                                                                                                            Dear Team, I am reaching out regarding a script I have implemented in Zoho FSM to automate the calculation of the End of Service date based on the End of Sale date in the Service and Parts module. Overview of the script: Fetches the End_of_Sale__C and
                                                                                                          • Zadarma + Zoho CRM Integration – Missed Calls Saved as Contacts Instead of Leads

                                                                                                            Hello everyone, I’m looking for input from anyone with experience using the Zadarma + Zoho CRM integration. Currently, I’m seeing that missed calls are automatically being created as Contacts instead of Leads. From a CRM perspective, this doesn’t make
                                                                                                          • Zoho Books | Product updates | September 2025

                                                                                                            Hello users, We’ve rolled out new features and enhancements in Zoho Books. From PayNow payment method to applying journal credits to invoices and bills in other locations, explore the updates designed to enhance your bookkeeping experience. Integrate
                                                                                                          • How to update Multiple Users field in Quote Module from Deal Module

                                                                                                            Scenario : Deal Module having Multiple User Field (Presales Engineer) which having more than 1 User and through Deluge Script I need to get that Users Details and need to put into Multiple User Field (Presales Engineer) of Quote Module. Note: Both Module
                                                                                                          • Auto-sync field of lookup value

                                                                                                            This feature has been requested many times in the discussion Field of Lookup Announcement and this post aims to track it separately. At the moment the value of a 'field of lookup' is a snapshot but once the parent lookup field is updated the values diverge.
                                                                                                          • Clone a Module??

                                                                                                            I am giong to repurpose the Vendors module but would like to have a separate but very similar module for another group of contacts called Buyers. I have already repurposed Contacts to Sellers. Is it possible to clone (make a duplicate) module of Vendors
                                                                                                          • Advance PDF creation from CRM data

                                                                                                            I'm trying to create a PDF export of data in the CRM. My problem is I want a pretty complicated format for the data. I'm trying to export multiple modules worth of data, with nested one-to-many relationships between the modules. Along with that, I want
                                                                                                          • how to disable staff selection Zoho Booking integrated to SalesIQ?

                                                                                                            currently there is only one Consultant in my Zoho Bookings like this I integrate Zoho Bookings into Zoho SalesIQ to create a chatbot. Unfortunately, even though I only have one consultant for a consultation, the user have to pick the consultant. It will
                                                                                                          • Next Page