Kaizen#135 : Third Party Integration using Client Script

Kaizen#135 : Third Party Integration using Client Script

Hello everyone !

Welcome back to another enlightening Kaizen post! In this Kaizen post, we'll explore how to invoke a Third-Party API through Client Script. This enables you to seamlessly connect to external services and fetch dynamic data. Stay tuned to discover the step-by-step process of invoking a Third-Party API withi your client-side scripts. This post will answer the question on Importing data from third party API.


In this Kaizen post,

  1. Overview
  2. What are Connections?
  3. How to invoke a Connection in Client Script?
  4. Use Case 
  5. Solution 
    1. Create a Connection.
    2. Add to Trusted Domain.
    3. Invoke the connection in Client Script and populate the field using Client Script.
  6. Summary
  7. Recommended Reads


1. Overview



To accomplish Third Party Integration using Client Script,  you need to create a Custom service Connection and invoke the connection in Client Script. Once you get the response from the Third Party API call, you can populate or display the required data using Client Script. 


2. What are Connections?

Connections in Zoho CRM  is used to establish authentication with other Zoho or third-party services to perform integration with them. Check this Kaizen post to know more about Connections and Authentication types.

3. How to invoke a Connection in Client Script?

To invoke a Connection using Client Script, you need to use the invoke method with the required parameters.

Syntax :                  invoke(connection_name, url, method, param_type, parameters, headers)  




Note: 

           Whenever you want to make third party API calls, you need to whitelist them by adding the third party domain to Trusted Domain.                     


4. Use Case :

Zylker is a manufacturing organisation. Orders will be placed by the Salesperson by creating a record in the custom module "Requests" . The Admin wants to populate the distance between Manufacturer Location and Seller Location in the "distance" field using the Distance Matrix API.



5. Solution :
To populate the field "Distance" based on the response recevied from the third party API call using Client Script you need to follow the below steps.
  1. Create a Connection.
  2. Add to Trusted Domain.
  3. Invoke the connection in Client Script and populate the field using Client Script.

1. Create a Connection :

  • In Zoho CRM, go to Setup → Developer Hub → Connections and click "Create Connection"


  • Under "1. Pick Your Service" , select "Custom Services" and click "Create New Service".


  • Enter the following details and click "Create Service".



  • Now,  you will be prompted to enter the authentication credentials, Here it is the API Key. Enter the value and click "Connect".



2. Add to Trusted Domain:
  • Whenever you want to make third party API calls, you need to whitelist them by adding the third party domain to Trusted Domain.

  • To do this go to Setup → Security Control → Trusted Domain.


  • Click New Trusted Domain.


  • Enter the Name and Domain details and click Save.
3. Invoke the connection in Client Script and populate the field using Client Script.

  • The next step is to invoke the connection using Client Script using the invoke method.
  • For this, create a Client Script on Create Page of "Requests" custom module and specify the event as onChange Page event as follows and click Next.
     


  • Enter the below script and click Save.

Script :

  1. if (field_name == "Seller_Location" || field_name == "Manufacturer_Location") {
  2.     let origins = ZDK.Page.getField('Manufacturer_Location').getValue();
  3.     let destinations = ZDK.Page.getField('Seller_Location').getValue();
  4.     let dist = ZDK.Page.getField('Distance');
  5.     dist.setReadOnly(true);
  6.     var response = ZDK.Apps.CRM.Connections.invoke("measuredistance", `https://api.distancematrix.ai/maps/api/distancematrix/json?`, "GET", 1, { "origins": origins, "destinations": destinations }, {});
  7.     let distance = response._details.statusMessage.rows[0].elements[0].distance.text;
  8.     dist.setValue(distance);
  9. }
  • Here the values of the fields Seller_Location and Manufacturer_Location are captured using getValue() and are stored in origins and destinations respectively. The Third Party API - Distance Matrix returns the distance between origins and detstinations. So you need to pass these two parameters in the invoke() method and  capture the response and populate the distance to the "Distance" field using setValue() method.
  • As per the following syntax, you should pass the required parameters.
Syntax : invoke(connection_name, url, method, param_type, parameters, headers) 

  • The connection_name  is "distanceMatrix".
  • The URL is https://api.distancematrix.ai/maps/api/distancematrix/json?&key=${key}Note that the "key" is represented as ${key} as it is a variable. This is the variable name that you mentioned while creating the Connection.
  • GET is the method as we are fetching data.
  • For URL parameters , you should mention 1.
  • Parameters are { "origins": origins, "destinations": destinations } 
  • {} represents that there are no headers.
  • Now, create a record in Requests and enter the location details. You can see the "Distance" field getting populated as shown below.

  • Here is how the Client Script works.


6. Summary :

In this post we have discussed,
  • How to invoke a third-party API call in Client Script
  • How to create a Custom Service Connection
  • How to use Connections in Client Script.
  • How to add a new Trusted Domain
  • How to populate a field with the response of a third-party API call.

7. Recommended Reads :
______________________________________________________________________________________________________________________________________

Previous post :  Kaizen #134 : Manipulating Rich Text Field (RTF) using Zoho CRM APIs | Kaizen Collection : Home.                     

Join us for our upcoming Zoho CRM Developer Series: Zoho CRM APIs, where you can explore more about Zoho CRM APIs. Register Now!  
  



Cheers!
Maadhari M






    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





                                                  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

                                                                                                  • Integrating Zoho Creator with Google Drive

                                                                                                    I am interested in using Google Drive as a convenient repository to push files from file upload fields in my creator app. I am wondering if people have come up with best practices for this or even how viable it is. https://developers.google.com/drive/api/guides/manage-uploads#simple
                                                                                                  • Subform Lookup field showError doesn't clear in Client Script

                                                                                                    I have a lookup fields Deal, Account and Lead in Subform, I am checking if its null or not If its null It shows an error, but when I select some value for the Lookup Field it doesn't clear the error , for other fields such as single line or pickup etc.
                                                                                                  • Option to Manually Add and Verify DMARC Record

                                                                                                    Dear Zoho Mail Team, When configuring a new domain in Zoho Mail, we currently have the option to automatically configure the MX, SPF, and DKIM records. For each of these, we can either allow Zoho to create the records or manually add them to our DNS and
                                                                                                  • Zoho Desk & Tasks

                                                                                                    Hi, I'd like to be able to create a set of tasks each time a customer request comes in, as I understand it, currently each would need to be create manually. Project is too much of an overhead for what we want to use. Effectively in various use cases we
                                                                                                  • Working with Products that are non-tangible

                                                                                                    How does one create a 'service' in products? Is there a way to disable inventory functions for things like Sofware as a service? The services module doesn't look to be much help either. Not sure how to do this in CRM
                                                                                                  • Weekly Tips: Categorize Your Emails with Tags

                                                                                                    We send and receive hundreds of emails each week—ranging from work-related updates, personal messages, important documents, and even spam. With so many emails flooding your inbox, it can quickly become chaotic. Some emails are urgent, some are for reference,
                                                                                                  • Create vendor via API

                                                                                                    The Zoho Books web ui has an option to add a new vendor. Though I can't find an API to create a vendor. Is there an API available for creating a new vendor? Regards, Vinod
                                                                                                  • Function to check frequency of customer ordering patterns

                                                                                                    Hi, I'm no coder, so I thought I could make use of Chat GPT to generate some Deluge script to create a function that would check order frequency of our customers so that I could send an email if they go beyond their usual order pattern. Chat GPT and Claude
                                                                                                  • Customization of "List Price" naming convention

                                                                                                    Surely this has been brought up before, but does Zoho plan to allow the customization of the List Price field? For example, the ability to rename to: Sell Price Sale Price Market Price Ticket Price etc etc
                                                                                                  • Dashboard Analytics - Time to fill a job

                                                                                                    Hello! I'm creating a dashboard and want a chart that displays the recruitment SLA (time to fill) of job openings. I created a report that retrieves the SLA for each job opening. However, when generating the chart, the information does not appear as I
                                                                                                  • Deluge Script to Reopen Ticket if Tasks are not Completed

                                                                                                    I have the following script, my goal is to have it automatically reopen the ticket when the ticket is closed if there are Activities assigned to the ticket that are not "Completed". This script seems to reopen the ticket if there are any tasks at all,
                                                                                                  • Zoho People U.S. Compensation Setup

                                                                                                    We're new to Zoho and Zoho People Plus. So far, we like what we see as an HRIS system to suit our small USA-based (under 20-person) non-profit. However, we can't figure out how to configure the Compensation Service to reflect our workplace. We'd simply
                                                                                                  • Zoho Desk - Archiving Contacts

                                                                                                    Hi, We have a lot of customers in Zoho Desk with associated contacts. When a contact leaves we want to be able to still have their tickets in our history as this is important. But we don't want to have all these contacts that no longer work for the company.
                                                                                                  • Zoho Desk integration with Power BI

                                                                                                    Hi, I want to be able to create a Power BI report which has live updates of ticket data from zoho desk, is this possile at all? Thanks Jack
                                                                                                  • Unified WhatsApp Number Management in Zoho Desk and SalesIQ

                                                                                                    Dear Zoho Desk Support Team, We are currently utilizing both Zoho Desk and Zoho SalesIQ for our customer support operations. While both platforms offer WhatsApp integration, we are facing challenges due to the requirement of separate WhatsApp numbers
                                                                                                  • Zoho books not accepting valid state code via api

                                                                                                    Hello, I am using make.com to create a contact and then invoice for a Shopify orders. However, while creating contact I'm getting "please provide a valid state code" error even though I'm providing correct state code. For example I'm providing MH as state
                                                                                                  • Create View to See Tickets Closed within the last 3 days

                                                                                                    I'm trying to create a view in Zoho Desk that shows me "recently closed ticket," which I will define as tickets closed in the last 3 days. I want this view to update so that whenever I click to view it is recalculates and shows me tickets closed within 3 days from that moment. When I try to Create a view and use the criteria of "Ticket Closed Time" I have to specify a discrete time frame (on or before a specific date). It doesn't allow me to define time/date dynamically like I can do with date fields
                                                                                                  • I'm so confused by the new (?) look

                                                                                                    I've been off Notebook for a long time, neglecting the app and never visiting the website. I decided to renew my commitment to it. It looks completely different! When I logged on before (app or browser page) I'd see a very pretty display of my multiple
                                                                                                  • Conexão de Meta Ads - A busca pelo Cálculo do ROI

                                                                                                    A empresa onde trabalho está em busca de calcular melhor o retorno sobre o investimento de das suas campanhas do Meta Ads. A zoho junto com a Google fez um excelente trabalho e disponibilizou o cálculo desse retorno de forma maestral com o dashboard abaixo.
                                                                                                  • Email alias per task list so these tasks don't get listed under a 'General' task list that we didn't create nor use

                                                                                                    Using an email alias to add tasks is very good for forwarding emails directly into Zoho Projects however everything gets listed under a 'General' task list which is counter-intuitive. It would be good to have an email alias for each task list so we can
                                                                                                  • Can Zoho Flows repeat Actions more than once?

                                                                                                    I'm attempting to make an intentional Zoho Flow loop using the below layout. However, when "WithinLimit" condition is met, the program fails to execute the action "Get & Add Request Co..." again. Is this by design? Is Zoho Flows unable to repeat actions
                                                                                                  • Workflow to auto close Open Deals after 7 days?

                                                                                                    I want to set up a Workflow to Automatically close Deals as Lost after 7 days from their created date, (Regardless of activity or not) I am new to Zoho however I read 2 different ways to do it. 1 required to create a custom Date field and the other looked
                                                                                                  • Enable Filtering by Notes in Accounts & Other Modules

                                                                                                    I noticed that we have the option to filter by notes in the Contacts module, which is great. However, in our company, we add notes specific to an Account, and currently, there's no option to filter Accounts with notes. Can this be enabled? It would also
                                                                                                  • Zoho Marketing Automation Cannot Sync Lookiup Fields

                                                                                                    Hello all, It seems that Zoho MA cannot sync Lookup fields from the CRM. Can you confirm if this is the case? Is there a workaround? Do you know if Campaigns can sync with custom modules and also with Lookup field in the CRM? Thank you!
                                                                                                  • Mail > Columns

                                                                                                    How do I add/remove columns in Mail views? I sent individual emails to multiple coworkers which I then moved to my Coworkers Folder. When I then view the Coworkers folder, all I see is the Subject (same for all), and the sender (Me).
                                                                                                  • Undo/redo when composing Mail

                                                                                                    Where is the undo/redo button when composing mail? I've new to Zoho, I've looked, I've searched and can't find it. What am I missing?
                                                                                                  • How can I edit the Picklist History?

                                                                                                    I was working with some custom functions in CRM that inadvertently triggered unwanted changes in a picklist history for the Accounts module. It is absolutely essential for the business that I roll these changes in the subform back because they throw off
                                                                                                  • Picklist reference value in REST

                                                                                                    picklist options can be configured to have a different reference value than the displayed one, should be helpful in things like multilanguage: https://help.zoho.com/portal/en/kb/crm/customize-crm-account/translations/articles/translations is there a way
                                                                                                  • Mass replace picklist value

                                                                                                    I need to rename picklist option from "Option 1" to "Option 5". The value "Option 1" is set in about 1000 records in my CRM module. I am also using the that picklist in Reports and Workflows extensively. should I: A/ rename the option value and its reference
                                                                                                  • What are the consequences of renaming a picklist value?

                                                                                                    What are the consequences of renaming a picklist value?
                                                                                                  • Foreign currencies behaviour

                                                                                                    Ladies and Gentlemen, It's really good to hear that you are developing your product, which I like a lot, but honestly, I'm sure you have much simpler issues to deal with. Foreign currencies operations have a HUGE lack in your product. Transferring from
                                                                                                  • Journey : "Added to segment" trigger doesn't work automatically

                                                                                                    Hello, I’m experiencing an issue with our Marketing Automation 2.0 integration with Zoho CRM. We have multiple segments defined in Marketing Automation, each with criteria based on field values synced from Zoho CRM. If a field value changes in Zoho CRM,
                                                                                                  • Creator Simplified #6 : Create custom buttons for multiple records using form object

                                                                                                    Hey Creators! It's learning time! Requirement Perform actions for multiple records in a single button-click using a form object. Sample Use-case In an employee management app, the HR needs to send a mail on a button-click to all employees regarding a
                                                                                                  • OAuth integration issues

                                                                                                    I'm experiencing persistent OAuth errors when trying to connect Make with Zoho API. I've tried multiple approaches but keep encountering the following issues: First error: 'Invalid Redirect Uri - Redirect URI passed does not match with the one configured'
                                                                                                  • Bulk Delete Images

                                                                                                    How do I bulk Delete Images from Zoho Campaigns. We have been using the Zoho since 2019 and can still only see the option to delete images one by one and we have a lot of old Campaign imagery we don't need anymore. Thanks!
                                                                                                  • Whatsapp Notification For Cliq

                                                                                                    We have integrated WhatsApp Business into Zoho CRM, and messages are coming through to the CRM. However, I want a notification message to be sent to the data owner in Cliq when a new message arrives. This doesn't seem possible through rules. Is there
                                                                                                  • Bigin iOS app update

                                                                                                    Hello everyone! In the latest iOS (v1.11.3) version of the Bigin app, we have introduced the following features: Initiate a conversation with a contact on the ‘Messages’ module. Introduced a templates icon in the existing WhatsApp conversation. An option
                                                                                                  • Difference between the 'field_read_only' and 'read_only' fields exposed by the Fields Meta Data API.

                                                                                                    The API documentation describes the 'field_read_only' field to indicate that a field is read-only always, implying that no user can ever get the write access for this field. The 'read_only' field's description states that its value can change depending
                                                                                                  • Zoho eCommerce frontend

                                                                                                    Questions about the Zoho eCommerce frontend 1) can different frontends (websites) be used? Zoho eCommerce is the backend with 3 or more websites. 2) how can the Zoho eCommerce frontend be customized to better fit Responsive Breackpoints? thanks best regards
                                                                                                  • Dynamic Date Filtering for KPI Widgets – Need Help with Query Table

                                                                                                    Hello, I'm seeking help with setting up dynamic date filtering for my KPI widgets in Zoho Analytics. Below is an overview of my setup and the issues I'm facing: Why: I need my KPI widgets to update dynamically based on a date range selected via a dashboard
                                                                                                  • Next Page