Kaizen #59 - Creating alerts and custom messages using Client Script

Kaizen #59 - Creating alerts and custom messages using Client Script

Hello everyone! 
We are happy to resume our Zoho CRM Developer Community series - The Kaizen series!
Welcome back to the new start of Kaizen!
This post is about Client Script and its simple use cases involving ZDK Client functions.

What is Client Script?

The Client Script feature gives you a seamless platform for achieving and extending your business cases in Zoho CRM by allowing Java Script code execution in your browser. It enables you to configure events for the UI components and define the actions once those events are triggered. 

The ZDK Client Functions available in Client Script are,

ZDK Client Function
Description
showMessage 
To display a text message on create/clone/edit/detail(canvas) page.
showConfirmation
To display a confirmation box with accept and reject message on  create/clone/edit/detail(canvas) page.  
showAlert 
To show alert message on create/clone/edit/detail(canvas) page.
openMailer
To open mailer component from detail(canvas) page.

Use Case

Let us consider that you want to achieve the following using Client Script.
  1. Calculate age based on Date of Birth and display the message "Age is more than 80" whenever the age is above 80 in create page of Policyholder module.
  2. Show the alert message "You cannot change the Rating of a verified account" whenever you try to update the field Rating in Accounts module.
  3.  When you click the mail button on detail(canvas) page, ask for confirmation and open a mailer window.

Solution using Client Script

Note:

The solution listed in this post includes detail(canvas) page and create page.
To create a canvas page, 
  • Go to Setup > Customization > Canvas
  • Click Create Record Detail Page. 
  • On the Create a Custom Record pop up that appears, select the module as "Accounts" and select the required layout for the canvas page
  • Choose a template from the gallery and click Select.
  • Enter a name and save the canvas page.
  • Click Canvas Assignment and assign the page to the required profiles.
  •  Click here for more details on creating a canvas page(Customizing the record detail page).
1. Calculate age based on Date of Birth and display the message "Age is more than 80" whenever the age is above 80 in create page of Policyholder module

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

  • Enter the following script in the Client Script IDE and click save.
  1. function  getAge(dateString) 
  2. {
  3. var today = new Date();
  4.  var birthDate = new Date(dateString);
  5. var age = today.getFullYear() - birthDate.getFullYear();
  6.  var m = today.getMonth() - birthDate.getMonth();
  7.  if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) 
  8. {
  9.    age--;
  10. }
  11.  return age;
  12. }
  13. let age = getAge(value);
  14. var age_field = ZDK.Page.getField("Age");
  15. var category_field = await ZDK.Page.getField("Category");
  16. age_field.setValue(age);
  17. if (age > 80) {
  18. ZDK.Client.showMessage('Age is more than 80', { type: 'info' });
  19. }
  • You can see the code working from the create page.  You can also see how the client script works using the Run component of the Client Script IDE.

  • You can use any of the following types in showMessage() function
Possible 'type'
Script
info
ZDK.Client.showMessage('message', { type: 'info' });


warning
ZDK.Client.showMessage('message', { type: warning });

error
ZDK.Client.showMessage('message', { type: error });

success
ZDK.Client.showMessage('message', { type: success });

2. Show the alert message whenever you try to update the field Rating

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

  1. ZDK.Client.showAlert('You cannot change the Rating after account creation');
  • Here is how the Client Script works. You can also see how the client script works using the Run component of the Client Script IDE.

3. Configure the mailer box with the click of a button

First of all, you need to add the button to the detail(canvas) page.
  • Go to Setup > Customization > Canvas.
  • Right click on the Canvas page for Accounts module and click Edit.
  • Click Elements, drag and drop the button wherever required and specify a label for the button.
  • Right click on the button, select Add Element ID and enter the ID of the button in the pop up that appears.
  • Once the button is created, you can configure Client Script in two ways:
  • Right click on the button--> Add Client Script-->onClick. The Client Script IDE appears with the event type as Canvas Button Event.
                                                             (or)
  • 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.
  1. var isProceed = ZDK.Client.showConfirmation('Do you want to open the mailer window?','Proceed','Cancel');
  2. //If user clicks Proceed button
  3. if (isProceed) {
  4. ZDK.Client.openMailer({ from: '', to: [{ email: '', label: 'ABC Industries' }], cc: [{ email: '', label: 'ABC Industries' }], subject: 'Greetings from ABC Industries!', body: ' ' });
  5. }
  • The showConfirmation() function will return a boolean value based on the user selection. You should capture this boolean value using a variable and write the actions based on the boolean value returned. Here the variable isProceed will capture the user response and based on that boolean value, the mailer box will get displayed.
  • Here is how the client Script works,

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!

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

Related Links


    • Sticky Posts

    • How to reach the official Zoho Support channels and avoid fake ones.

      Dear Customers, Thanks a lot for choosing Zoho! Our applications are built to help achieve your day-to-day business goals. We are committed to engaging with you, to understand and develop solutions that enhance your productivity.  We are happy and ready to help you use our services effectively. Understanding and avoiding fake support Just like using popular bank names and financial applications for phishing purposes, using Zoho and claiming to be providing Zoho Support or services with false numbers
    • Function #35: Close all tasks associated with a lead and create a new task.

      Welcome back everyone! Last week, we learnt how to close all tasks of a deal depending upon the deal stage. This week, let's look at a custom function that lets you close all of the tasks associated with a lead while simultaneously creating a new task, like when you need to halt all progress towards a lead while the lead is not available at the moment but create a reminder task. Business scenario: The success of a company, in one way or another, is determined by the leads it gets. Each lead is just
    • Zoho CRM Webinar - Redesigning Daily User Experiences with Canvas

      &lt;br&gt; Your users across roles use the CRM for day-to-day tasks that are necessary. Whether they perform their tasks on time, the right way, or at all depends on a lot of factors, including User Experience. Many businesses struggle with rigid layouts,
    • Join us at the Canada ZUG Meetup: What’s New in Zoho CRM

      Hello Zoho Community! Start your year with fresh insights into Zoho CRM’s latest updates and tools. Whether you're a CRM beginner or a experienced user, this meetup is crafted to help you optimise your processes and leverage new features. Explore practical
    • CRM Hack #2: Automate sending of birthday greetings to your customers.

        Hello everyone! What sets you apart as a sales person is your ability to add that personal touch to your business relationship with your customers. Sending a gift on a special day, or leaving a note wishing them on their birthdays, are small, yet significant actions that show your customers that you care. And these are actions done without any expectations :) You must be engaging with a lot of customers and it is highly unlikely that they all are your friends on Facebook or some social channel,
    • Recent Topics

    • Passing the CRM

      Hi, I am hoping someone can help. I have a zoho form that has a CRM lookup field. I was hoping to send this to my publicly to clients via a text message and the form then attaches the signed form back to the custom module. This work absolutely fine when
    • Zoho Flow - Add to Google Calendar from trigger in Zoho Creator App

      Hello! New to Zoho Flow, but I believe I have everything setup the way it should be however getting an error saying "Google Calendar says "Bad Request". Any idea where I should start looking? Essentially some background: Zoho Creator app has a trigger
    • Picklist field shows "none" as default

      Hello, Is there an option to avoid showing "none" as the default value in a picklist field? I also don't want to see any option displayed. My expectation is to have a blank bar, and then when I display the drop-down list, I can choose whichever I wa
    • Customer ticket creation via Microsoft Teams

      Hi all, I'm looking to see if someone could point me in the right direction. I'd love to make it so my customers/ end users can make tickets, see responses and respond within microsoft teams. As Admin and an Agent i've installed the zoho assist app within
    • Email authentication

      أريد التحقق من البريد الإلكتروني
    • What’s New in Zoho Analytics – December 2025

      December is a special time of the year to celebrate progress, reflect on what we have achieved, and prepare for what’s ahead! As we wrap up the year, this month’s updates focus on refining experiences, strengthening analytics workflows, and setting the
    • Marketing Tip #12: Earn trust with payment badges and clear policies

      Online shoppers want to know they can trust your store. Displaying trust signals such as SSL-secure payment badges, return and refund policies, and verified reviews shows visitors that your store is reliable. These visual cues can turn hesitation into
    • The improved portal experience: Introducing the template view for inventory modules, enhanced configurations, and PDF export support

      Availability: Open for all DCs. Editions: All Hello everyone, You can now achieve a seamless, brand-aligned portal experience with our enhanced configuration options and the new template view for inventory modules. Your clients will now be able to view
    • Zoho Analytics Bulk Api Import json Data

      HI, I’m trying to bulk-update rows in Zoho Analytics, and below are the request and response details. I’d like to understand the required parameters for constructing a bulk API request to import or update data in a table using Deluge. Any guidance on
    • Project Management Bulletin: December, 2025

      The holiday cheer is in the air and it’s time to reflect on the year that was. At Zoho PM Suite, we've been working behind the scenes on something huge and exciting all year and now we are almost ready—with just a bit of confetti—for our grand release
    • Inventory batch details

      Hi there, I'm trying to get the batch details of an item, here's what I've done so far. I've sent cUrl request to the below endpoint and I get a successful response. Within in the response I find the "warehouses" property which correctly lists all the
    • Function #50: Send Mass emails to your customers

      Hello everyone, and welcome back to our series! We have reached a milestone of 50 Functions, which means that we have automated 50 different tasks in Zoho Books. Every Friday, we have shared a nifty function aimed at either automating a task or streamlining
    • Auto check out after shift complete

      i'm just stuck here right now, i wanna know how to do this thing, now tell me, how can i configure a custom function that runs after complete shift time if employee forget to check-out ?
    • Restrict Users access to login into CRM?

      I’m wanting my employees to be able to utilize the Zoho CRM Lookup field within Zoho Forms. For them to use lookup field in Zoho Forms it is my understanding that they need to be licensed for Forms and the CRM. However, I don’t want them to be able to
    • Scan and Fill CRM Lookup Field

      Not sure if there is a reason why this isn't possible or if I'm just missing it. But I would like to be able to use the scan and fill feature on the mobile app to prefill the CRM lookup field and fetch the rest of the data in the form.
    • How to create a flow that creates tickets automaticaly everyday based on specific times

      Hi guys Does anyone know how to create a flow that will create tickets automaticaly in ZOHO Desk when a certain time is reached. Im havin a hard time configuring a flow that will create tickets automaticaly everyday during specific hours of the day For
    • ZOHO FLOW - ZOHO CREATOR - ZOHO WRITER : Get Related records

      Bonjour, J'ai besoin que vous m'ajoutiez la solution "Get related Records" dans la liste de choix de zoho creator (sous Zoho flow). En effet, j'ai besoin de récupérer les champs d'un sous formulaire pour l'ajouter à l'impression de mon document. Mer
    • Task Details on task template

      When creating a task template in settings that task details seem to be missing. Is it not possible to set the details of a task, such as the priority, type, reminder settings, and custom field values?
    • Option to Delete Chats in IM

      Currently, there is no option to delete any chats in IM, regardless of their source.
    • Will zoho thrive be integrated with Zoho Books?

      title
    • Connecting email for each department in ZohoDesk

      Hi! Could someone help me to go through connecting emails for each department?
    • How do I trigger a Flow based on a campaign response?

      Is there a way to trgiider a Zoho Flow based upon a lead opening an email sent via Zoho Campaigns? I see that the data is recorded in the 'Campaigns' section of Zoho CRM under 'Member Status' and I want to trgigger a flow based upon that record changing.
    • All Zoho Flows are filtered

      My two flows operate perfectly when I run them as a test, but when they're activated each run ends with a status of neither success, nor fail, but filtered. I haven't set up any filters. I don't see where to turn off filters. When I test run on a sequence
    • Creating Multiple Items on Sales Order

      Hi, I’m trying to automate some processes using Zoho Flow, specifically the creation of sales orders in my Zoho Inventory. However, Zoho Flow's Create Sales Order function can only add one item. I would like to include multiple items in a single sales
    • Problem Connection from Zoho Flow and Gravity Form

      I obtained my API key from Gravity Forms via WordPress. However, when I enter my Zoho Flow, it states: Gravity Forms says, 'You are not authorised to access the API." I tried recreating a new API key, but it is still not working.
    • Eventbrite Email Field in Zoho Flow Returns "Info Requested" Instead of Actual Email

      Hi Zoho team, I'm using Zoho Flow to connect Eventbrite with Zoho CRM. My goal is to automatically add event attendees as leads in Zoho CRM. I’ve set up the flow and mapped the ${trigger.profile_email}} field to the Email field in CRM. However, I'm running
    • "Invalid value passed for Product ID" Error in Zoho Flow "Create Sales Order" Node

      Hello Zoho Community, I’m facing an issue with Zoho Flow while trying to create a sales order in Zoho Inventory using the "Create Sales Order" node. Here’s a detailed explanation of my setup and the problem: What I’m Trying to Achieve I’m building an
    • Associating Project with an Account via Flow

      I'm using flow to create a Project based on a Deal status update using flow. The fields exist to pass the Account Name through properly, but when you view the Projects module in a CRM Account Record it doesn't automatically associate the new Project Record
    • How to follow up a member in a meeting?

      Hello, I make weekly meeting online with a lot of people. I want(I've been using calendly to do it). I want to do a follow-up to it. I want to send messages via Zoho-flow to all the member that participated in the meeting. How can I do it?
    • Setting Delays in Invoice Reminder Flow

      I am currently working on a flow that sends reminders for unpaid invoices. The flow is designed to delay actions until specific intervals before the due date: A reminder should be sent 7 days before the due date. A second reminder should be sent 3 days
    • Get Sales Orders Related to Inventory Item

      Dear Team, I'm just wondering if there is a way to get a list of all Sales Orders related to a specific Inventory Item. I did search all articles but couldn't find any article that could help.
    • Endpoint Central Cloud Asset Update from Fresh Service

      All, Does anyone use the asset management feature in Fresh Service? I'd like some help on building a flow to update asset attributes in Endpoint Central Cloud based off of an update to that same asset in Fresh Service. The trigger is "asset is updated"
    • Zoho Flow Export to Deluge

      It would be great to take a user built zoho flow and export the entire flow as a deluge script including having multiple connected applications (showing the API connections and webhooks) and different functionality in the other applications interacting
    • Action Iteration/Loop using Zoho Flow

      Trying to use Zoho Flow for automating following Context - A zoho form entry which has image upload field with upto 5 images setting and files are saved into Workdrive. After form is submitted need to create folder based on some fields and move files
    • Zoho Flow - Unable to evaluate formatDate with Zoho Invoice Date Field for Calendar Integration

      Hello Community, I'm trying to automate the creation of all-day events in Zoho Calendar whenever a new invoice is created in Zoho Invoice. I'm using Zoho Flow for this automation. My Goal: When an invoice is created with a specific "Event Date," I want
    • Zoho Inventory Sales Order Items

      I'm trying to build automation using Zoho Flow to add items to a Sales Order. In the automation options for both "create sales order" and "update sales order", The item ID is required. However, when I update the Sales Order, it's just replacing the item
    • Permissions for Azure Devops connection

      I am trying to set up a connection with our Azure DevOps org but it keeps giving me this error. On Azure I should be able to have admin-level access to everything. Can you please point me to which permission this is checking for so I can enable it?
    • Marketing Tip #1: Optimize item titles for SEO

      Your item title is the first thing both Google and shoppers notice. Instead of a generic “Leather Bag,” go for something detailed like “Handcrafted Leather Laptop Bag – Durable & Stylish.” This helps your items rank better in search results and instantly
    • Best way to start zoho inventory with bulk openning stock

      We are already using zoho book since long time for cars trading company. Now to streamline more, would like to import the excel data of closing stock of inventory to zoho inventory and to start on. Since we need to track each VIN (unique vehicle id number)
    • Confused by the distiction between matched and categorized when reconciling a bank statement an how to

      I used to use quickbooks. In quickbooks, it was possible to use the check writing feature to add an expense that was on the bank statement that did not go through the AP and check writing process. I would write a check, assign it a number like etf (for
    • Next Page