Kaizen#75 - Frequently Asked Questions on Client Script

Kaizen#75 - Frequently Asked Questions on Client Script

Welcome to another week of Kaizen! In this post, let us discuss some of the frequently asked questions in Client Script.

1. Where can you see the list of ZDKs supported by Client Script?

The Zoho Development Kit (ZDK) library comprises a rich set of Client and Web APIs that broaden the scope of Zoho Applications. You can utilize them to perform UI operations and trigger REST API calls. 
To view the documentation for ZDK, click the help icon in the Library under Information of the Client Script IDE.



2. Will the CRM API calls triggered from Client Script count into daily API limits?

Yes, every ZDK Web API in Client Script makes an  API call to Zoho CRM and  so every execution of a ZDK Web API affects the API limits.

3. What would be the correct way to set the value of a lookup field via Client Script?

You need to mention the id of the record along with the name when you try to set the value to a lookup field. 

Example:
Consider that there is a lookup field Category and the requirement is that it should be populated based on the Product selected by the user.
  • Battery, Thermostat, and Ignition Switch belong to the category of Electrical Switches.
  • Fuel level sensor, Light sensor, and Airbag sensor belong to the category of Sensors.
i.e. If the user selects the product "Battery", then the lookup field Category should get auto-populated as Electrical Switches.

Here is the code to accomplish this.


if (value.name == 'Airbag sensor' || value.name == 'Light sensor' || value.name == 'Fuel level sensor') {

//Populate value for lookup field Category based on the condition

ZDK.Page.getField('Category').setValue({ "id": "4967860000001049208", "name": "Sensors" });   

    }

else if (value.name == 'Ignition Switch' || value.name == 'Thermostat' || value.name == 'Battery') {

//Populate value for lookup field Category  based on the condition

ZDK.Page.getField('Category').setValue({ "id": "4967860000001049217", "name": "Electrical Switches" });

    }


Here is how the above script works.



4. How do I debug a Client Script in Zoho CRM?

You can use the log() statement to debug the script. The results of the execution of this log() statement will be displayed in the Messages panel of the Run option. Also, information about the execution status, logs, exception messages, and time taken for the execution are also displayed.

For example, consider the following script. It has two log statements. You can view the output of the log statements in the messages panel of Run option.


var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);

var field_obj = ZDK.Page.getField('Phone_Number');

log(field_obj.getValue());

log("Profile name of the user is "+ user.profile.name);

if(user.profile.name != 'Administrator')
{

    field_obj.mask({ character: '*', length: 5, reverse: true });

}



Any CRM Operation performed inside the run mode will get reflected in your Zoho CRM account.

5. Does Client Script support languages other than Javascript?

No. Client Script in Zoho CRM supports only Javascript.

6. Will a Client Script run for all the layouts of the module?

No. Client Script will execute only for the layout specified while configuring the Client Script. If you want the script to run for other layouts or all the layouts of a module, you should create a separate Client Script for each layout. 

7. What is the use of the Terminal section in the Client Script IDE?

You can execute the ZDK APIs instantly in the Terminal section of the Client Script IDE. For example, when you type the below script in the Terminal section and hit enter, you can see the alert message on the screen.


ZDK.Client.showMessage('Welcome to Client Script IDE', { type: 'info' });




8. When should you use onChange Page Event and onChange Field Event?


Field Event - onChange
Page Event - onChange
If you want the script to run only when the specific field is updated, you can use the Field onChange Event.

If you want the script to run whenever any of the fields on that page is updated, you can use the Page onChange Event. 


When you have to write a script for more than one field on the same page, you can use if and switch..case statements.


9. Using Client Script, how do I prevent the record from being saved when the value for a specific field entered is invalid?

To prevent a record from getting saved, you should follow the following steps:
  • You need to use the onSave event type since you want to prevent the record from getting saved.
  • Add "return false;"  statement.
  • Always display the error/alert/message, so that the user will know the why the record is not getting saved.
Example:
Consider that the field quantity should not have a value of less than 100. To accomplish this, you need to create a Client Script with the onSave event type, show an error message, and add a return false statement if the record should not get saved for that particular condition.



//Get the value of the field Quantity of Products 

var qty_field = ZDK.Page.getField("Quantity_of_products");

log(qty_field);

//Invoke the static method by passing the value of Quantity of Products

if(qty_field.getValue() < 100)
{
    qty_field.showError('The minimum value should be 100'); // or

   //  ZDK.Client.showMessage('The minimum value should be 100', { type: 'error' });//or

    //ZDK.Client.showAlert('The minimum value should be 100');//or

    return false;
}


Here is how the above script works.



10. What are all the places where the Client Script can run?
Currently, Client Script can be executed in the following pages of Zoho CRM.
  • Create Page
  • Edit Page
  • Clone Page
  • Detail Page (Canvas)
  • Create Page (Wizard)
  • Edit Page (Wizard)
11. Can Client Script run in Quick Create page?

No, currently Client Script in Zoho CRM cannot be executed in Quick Create Page.

12. Does Client Script support the Detail Page (Standard)? 

Currently, there is no support for the Detail Page (Standard) but it is in our roadmap.
Once this goes live, you will also be able to hide fields.



    • Recent Topics

    • 🚀 WorkDrive 5.0: Evolving from a file sharing app to an intelligent content management platform: Phase 2

      Hello everyone, WorkDrive's primary focus has always been to provide an intelligent and secure content management platform, simplify collaboration, and be the central repository of files for all Zoho apps. In our previous announcement, we unveiled the
    • Join our live webinar: Explore the WorkDrive TrueSync application!

      Hello everyone, We are thrilled to invite you to a live webinar focused on mastering the WorkDrive TrueSync application. Discover how to seamlessly sync your content between the cloud and your computer, ensuring smooth and efficient file management. Our
    • Creating and managing a Team Folder using WorkDrive TrueSync

      Hello everyone, Are you tired of constantly switching between your Desktop TrueSync app and the WorkDrive web app to create and manage Team Folders? We’ve made things easier for you. You can now create and manage Team Folders directly within the TrueSync
    • Live webinar: Getting the most out of WorkDrive in Zoho Workplace

      Hello everyone, We’re excited to invite you to our upcoming live webinar, where we’ll explore how to maximize your use of WorkDrive as part of the Zoho Workplace bundle. This is a fantastic opportunity to elevate your productivity and streamline your
    • Live webinar: Mastering data migration, organization, and team collaboration

      Hello everyone, We’re excited to invite you to our upcoming live webinar! Discover how to seamlessly migrate your data, optimize file organization, and boost team collaboration using Zoho WorkDrive’s powerful features. This is a fantastic opportunity
    • Edit images seamlessly with WorkDrive's built-in Image Editor

      Are you tired of switching between multiple tools just to make simple edits to your images? We understand the hassle, which is why Zoho WorkDrive now comes with a built-in image editing tool, powered by Zoho Annotator. This tool allows you to edit images
    • Supercharge your email workflow with WorkDrive's add-in for Microsoft Outlook

      Consider this: You’re handling a critical project, and your inbox is packed with important attachments, email threads, and client communications. The back-and-forth routine of downloading files to your computer, uploading them to WorkDrive, and manually
    • Secure and promote your content with Custom Watermarking

      Imagine this: You’re a professional photographer who regularly shares your work online with potential clients and collaborators. Recently, you notice that some of your images have been reposted without any credit or permission. This not only impacts your
    • Live webinar: Explore WorkDrive's seamless integrations with key Zoho apps

      Hello everyone, We’re excited to invite you to our upcoming live webinar, where we'll delve into the seamless integration of WorkDrive with other key Zoho applications! This is a fantastic opportunity to enhance your productivity and streamline your workflows
    • Join us in Singapore for the Zoho WorkDrive User Group meetup!

      Hello, everyone! Exciting news! We'll be hosting an upcoming Zoho WorkDrive user group meetup in the beautiful city of Singapore this November. At this Zoho User Group meetup, we'll guide you through ways to use WorkDrive as a platform and build custom
    • WorkDrive TrueSync now supports ARM64-based Windows devices!

      We’re excited to announce that the Zoho WorkDrive TrueSync app now fully supports Windows devices with ARM64 architecture! Whether you're working on an ARM-based device or an x64 processor, you can now enjoy the same seamless file synchronization experience
    • Live webinar: 2024 recap of Zoho WorkDrive

      Hello everyone, We’re excited to invite you to our year-end live webinar! This session will take you through the transformative features and updates we’ve introduced in Zoho WorkDrive this year, helping you streamline document management like never before.
    • Option to Disable Download for Documents Shared via Permalink

      Dear Zoho Writer Team, Currently, when sharing a Writer document using the regular permalink (Collaborators with external users), there is no option to restrict the ability to download the document. While the external share link allows such restrictions,
    • Live Webinar: Optimizing back-office operations in the manufacturing industry to maximize profitability

      Hello everyone, We’re excited to invite you to our upcoming live webinar on February 6! Discover how Zoho WorkDrive can help manufacturing businesses optimize back-office operations, improve efficiency, and boost profitability. Our product experts will
    • Important update for WorkDrive TrueSync users in China Data Center (CN DC) & Chinese language users in other DCs

      Dear WorkDrive TrueSync users, We recently identified an issue affecting users who have set their WorkDrive TrueSync app language to Chinese (Simplified/Traditional). During the auto-update process, the app would not restart automatically and unexpectedly
    • Live webinar: Streamlining legal operations: Leveraging Zoho WorkDrive for law firm success

      Hello everyone, Managing legal documents across departments and jurisdictions can be complex, but it doesn’t have to be. Join us on March 6 for an exclusive webinar where we’ll show you how Zoho WorkDrive empowers legal teams to stay compliant, organized,
    • Calendar not working

      Are we the only ones. On any browser we cannot click on any of our calendar appointments and get them to open. They just make the browser loop. WE have reached out and have been told they are working on it. The office staff are really stuck. The point
    • [Live Webinar] New in Zoho WorkDrive: AI enhancements, Data Loss Prevention, Version Controls, and more

      Hello everyone, We're excited to bring you another round of powerful updates in Zoho WorkDrive! Join us on May 15 for an exclusive live webinar where we’ll unveil the latest features designed to enhance your team’s productivity, collaboration, and data
    • How to Download a File from Zoho WorkDrive Using a Public Link

      How to Download a File from Zoho WorkDrive Using a Public Link If you're working with Zoho WorkDrive and want to download a file using a public link, here's a simple method to do so using API or a basic script. This approach helps developers or teams
    • WorkDrive TrueSync for macOS 26 (Tahoe) Beta

      Hello everyone, With Apple unveiling the macOS 26 (Tahoe) Beta, we know many of you are eager to explore the latest features and enhancements. We’re excited to support your enthusiasm! As part of our commitment to delivering seamless cross-platform experiences,
    • domain not verified error

      Hi when i try to upload a video from zoho creator widget to zoho work drive iam getting domain not verified error.I don't know what to do .In zoho api console this is my home page url https://creatorapp.zoho.com/ and this is my redirect url:www.google.com.Iam
    • Live Webinar: Getting Started with Zoho WorkDrive - A Complete Overview

      Hello everyone, We’re excited to invite you to our upcoming live webinar! Discover how to set up your team, bring in your data, and make the most of WorkDrive’s collaboration, organization, AI, and security capabilities. This session is perfect for anyone
    • Calendly One-way sync- Beta Access

      Hello Community, Many of our Zoho Calendar users have expressed their interests in Zoho Calendar and Calendly integration. We've been tightly working on with Calendly team to provide a two-way sync between Calendly and Zoho Calendar. However, there have
    • The year that was at Zoho Calendar 2023- Part 2

      In continuation with our previous post on all the exciting updates and improvements that have shaped Zoho Calendar over the past 12 months, Lets delve into more: Bring your calendars together- Introducing Zoho Calendar and Outlook calendar synchronisation
    • Tip of the week #18: Change the event organizer in Zoho Calendar.

      We cannot always be available to conduct an event when we organise one. In these circumstances, you can use Zoho Calendar to change the event organizer at any moment before the event begins. This way, you can avoid cancelling the event while still taking
    • Tip of the week #20: Create and manage multiple personal calendars.

      Zoho Calendar provides users with the facility to create and manage as many calendars as required. All these calendars can be managed and edited as per user requirements. You can alter the calendar view, make changes to the calendar theme, share the calendar
    • Tip of the week #24: Subscribe to the calendars of a Zoho Calendar user.

      Calendars that are created by Zoho Calendar users can also be added to your Zoho calendar. All public calendars listed by the users will be available when you enter the email address. You can choose the calendar you need to subscribe to. Once the email
    • Tip of the week #26: Import/ Export calendars in Zoho Calendar.

      Any calendar on the web or calendars that you create in any other calendar application can be imported in to Zoho Calendar. This will help you to add the events from the calendars that you import to your Zoho Calendar. You also have the option to export
    • Removing calendar for zoho email group

      How do I make it so that an email group created in Zoho Mail does NOT have a calendar? I have a couple groups for our phone systems voicemails - one for each department. Voicemail recordings are sent to this groups email address so they have access to
    • Tip of the week #27: Edit personal calendars in Zoho Calendar.

      In Zoho Calendar, the personal calendars you create can be edited to make changes you need to make. Edit a Personal Calendar The following changes can be made to the personal calendar by editing it: Calendar title Calendar color Reminders and Description
    • Tip of the week #28: Show/ hide, enable/ disable and empty/ delete your calendars in Zoho Calendar.

      The popularity of online calendars has soared in recent years. It's used both for personal and professional reasons. Calendars have evolved into an effective productivity tool in our lives, from creating events for birthdays and anniversaries to scheduling
    • Tip of the week #30: Share calendars publicly in Zoho Calendar.

      In Zoho Calendar, calendars that are created under My Calendars can be shared publicly. Making your calendar public allows others to view it. When you need to share your calendar with a larger group, public sharing can help. You can restrict others from
    • Tip of the week #31: Share your personal calendars within organization.

      Keep your Organization members aware of what's happening. In Zoho Calendar, you can share your personal calendar with all the members in your organization using the Share with org option.When you enable org sharing for a particular personal calendar,
    • Tip of the Week #33: Appointment scheduler in Zoho Calendar.

      In Zoho Calendar, you can use the Schedule Appointment option to share your appointment request form with the public, allowing people to fill out the form to request an appointment with you. This form can be embedded on your website or blog. Visitors
    • Tip of the Week #34: Embed Calendars using Zoho Calendar

      You can make your calendars public and visible to the general public by embedding them in your websites/blogs using Zoho Calendar. You can use the embed code to add your own calendars to your website's/ blog's HTML code, and the calendar will appear on
    • Tip of the week #35: Migrate to Zoho Calendar from Google Calendar.

      If you are looking to move your Google Calendar events to Zoho Calendar, never worry about missing out the events from your Google Calendar. You can migrate the events from Google Calendar using the export option and import it to Zoho Calendar and manage
    • Tip of the week #36: Migrate to Zoho Calendar from Outlook Calendar.

      If you've been using Outlook calendar and looking to migrate to Zoho Calendar, you can seamlessly export your calendars from Outlook and import them into Zoho Calendar without losing any events, participants, and the reminders set for each event. To migrate
    • Shared calendar issues and duplications

      Apparently there was a calendar update?  Now when I schedule an event for a team member that has shared his calendar with me, the event makes me the organizer and adds the event to my calendar as well.  Previous to this "update" I would scheduled an event
    • Subscribed Calendar

      Hi i have subscribed to a calendar for Holidays in Canada it shows all the holidays perfectly but every one of them has the word Canada before the rest of the name is there a way to remove that word Canada? It takes up a lot of space in the square on
    • The year that was at Zoho Calendar 2023- Part 1

      Hello, amazing community members! Happy new year from all of us here at Zoho Calendar. As we begin the new year, we'd like to thank each and everyone of our community members for your unwavering support and love that you have shown for Zoho Calendar.
    • Next Page