Client Script: How to Register Customer Complaints Quickly Using Commands in Zoho CRM

Client Script: How to Register Customer Complaints Quickly Using Commands in Zoho CRM

Requirement Overview

A Zoho CRM user wants to register customer complaints quickly by triggering a Client Script using shortcut keys, instead of manually navigating to the Complaints module and creating records.

Use-case

Consider an electronics shop that sells products such as mobile phones, headphones, and other electronic accessories. When a customer contacts the support team through a live call to report an issue, the CRM user needs to register the complaint quickly.

We can use Commands in Zoho CRM Client Script to:

  1. Trigger a temporary pop-up form using a configured shortcut key.

  2. Collect customer details, product information, and the complaint description.

  3. Check whether the product exists in Zoho CRM and retrieve its product code.

  4. Check for an existing complaint with the same identifier and ask for confirmation if a duplicate is found.

  5. Create a new complaint record directly from the script.

This helps support users register complaints faster, reduce manual navigation, and improve efficiency while handling live customer calls.

Alert
Key Benefits:
  1. Faster complaint registration using shortcut keys.
  2. Reduced manual navigation between CRM modules.
  3. Automated product lookup and duplicate checks.
  4. Improved efficiency during live customer support calls.
Info

Permissions & Availability

-> Users with the Manage Extensibility can configure & setup Client Script.
-> Users with the Manage Sandbox permission can manage the sandbox and test this use-case.

Configuration

To have a simple understanding on above explained use-case, we will explore how a client script will be triggered based on the command from anywhere and anytime within Zoho CRM.

Commands is a new dimension of Client Script that enables users to trigger script anytime and anywhere within Zoho CRM.  i.e. Now, users can execute Client Script directly using Personalized Shortcut Keys or Command Palette.

Follow the steps below to configure the Client Script for this use case:

1) Provide the basic information, like Name and Description based on script purpose.

2) In the Category Details section, please choose the following:
  1. Category as Commands.

The Code

  1. //creating a temporary pop-up form with input labels
  2. //4 input labels - Customer Name || Customer Email || Product Name || Complaint Report
  3. var inp = ZDK.Client.getInput([{ type: 'text', label: 'Customer Name' }, { type: 'text', label: 'Customer Email' }, { type: 'text', label: 'Product Name' }, { type: 'text', label: 'Complaint Report' }], 'Complaint Registration', 'OK', 'Cancel');

  4. //Checking if any Product exist with same name in Zoho CRM
  5. var prod = ZDK.Apps.CRM.Products.searchByCriteria("(Product_Name:equals:" + inp[2] + ")");
  6. console.log(prod);
  7. console.log(prod[0]._Product_Zcode);
  8. prodCode = prod[0]._Product_Zcode;

  9. //Concatinating CustomerName, Product Name, Product Code
  10. var res = inp[0] + "-" + inp[2] + "-" + prodCode;
  11. log(res);

  12. //Checking if any complaints with same concatinated name in Complaints module
  13. var comp = ZDK.Apps.CRM.Complaints.searchByCriteria("(Name:equals:" + res + ")");
  14. log(comp);
  15. log(comp.length)

  16. // var contact = ZDK.Apps.CRM.Contacts.searchByEmail(inp[1]);
  17. // console.log(contact);
  18. // contID = contact[0]._id;
  19. if (comp.length > 0) {
  20.     var response = ZDK.Client.showConfirmation('Already there is an existing complaint with same complaint ID!\n Are you sure you want to create new Complaint?');
  21.     console.log("entered inside if")

  22.     if (response == true) {

  23.         console.log("entered inside record creation")
  24.         var complaint = new ZDK.Apps.CRM.Complaints.Models.Complaints();
  25.         complaint.Name = res + "(New Complaint)";
  26.         // complaint.Customer = contID;
  27.         var response = ZDK.Apps.CRM.Complaints.create(complaint);

  28.         ZDK.Client.showMessage('New Complaint is succesfully registered.', { type: 'info' });
  29.     }
  30. }
  31. else {
  32.     console.log("entered inside record creation - else part")
  33.     var complaint = new ZDK.Apps.CRM.Complaints.Models.Complaints();
  34.     complaint.Name = res + "(New Complaint)";
  35.     complaint.Customer = contID;
  36.     var response = ZDK.Apps.CRM.Complaints.create(complaint);

  37.     ZDK.Client.showMessage('New Complaint is succesfully registered.', { type: 'info' });
  38. }
  1. Client Script Code Explanation

1. Collect complaint details: Displays a temporary pop-up form to enter the Customer Name, Customer Email, Product Name, and Complaint Report.

2. Fetch product details: Searches the Products module using the entered product name and retrieves the corresponding product code.

3. Generate a complaint identifier: Combines the Customer Name, Product Name, and Product Code to generate a unique complaint identifier.

4. Check for existing complaints: Searches the Complaints module for an existing record with the same identifier.

5. Confirm duplicate complaints: If a matching complaint exists, asks the user to confirm whether they want to create another complaint.

6. Create the complaint: Creates a new record in the Complaints module and displays a success message.

Working Demo - Screencast


AlertTo ensure a smooth implementation, we recommend configuring and testing the setup in the sandbox environment before deploying it to production.

TIPS - Avoid Common Errors

-> Ensure to use the correct API Names for both Module & Fields in the script.

-> To ensure you get the intended output, we would suggest you to add logs() || console.log() to each variable to check the output for seamless functionality. i.e., you could view the output in the "Messages" tab within Client Script IDE for each logs() print. To view console logs, you could follow - "Right Click on browser page >> Inspect >> Console".

-> In case the expected functionality does not work, then try the script by verifying each output & loop along with that, cross-verify the syntax of each ZDK Client/CRM API method in the provided sample help document. 

InfoSample Scripts for each ZDK Client/CRM APIs methods - Help Reference
Notes
Notes: Refer to the following Guide - Article to learn the best practices for Optimizing the code and various ways to deploy Client Script across Zoho CRM.



If you need any further clarifications, please don’t hesitate to contact partner-support@zohocorp.com.

Notes
Additionally, we kindly ask all Europe and UK Partners to reach out to partner-support@eu.zohocorp.com.