Use client scripts to fetch data from third party applications or websites | Online Help | Qntrl

Business case 3: Use client scripts to fetch data from third party applications or websites

While designing forms, we might sometimes want to display data from other websites or applications like stock rates, flight status, freight details, weather updates, and so on. To fetch such information from third party websites or applications and display it in fields while creating cards, client scripts can be used.
 

Business Scenario

Ryan runs a holiday agency. He uses Qntrl  to automate booking requests of his customers. Ryan wishes to display the weather forecast of the holiday destination when a client books the holiday package. He also wants the forecast to be updated automatically if a client changes the destination.
 

Solution

To achieve this, Ryan can make use of any weather forecast website’s API in Qntrl’s client script and display the weather and temperature when the user selects a destination. 

Sample Configuration 

Step 1: Create an orchestration

Create a new orchestration—Booking Request Orchestration—and add fields to record the client’s request.
  1. Add a Dropdown field— Choose a travel destination —and add dropdown values of states like Alabama, Alaska, California, Florida, and so on.
  2. Create 2 Single-Line fields to record Destination’s weather and Destination’s temperature


Once the form is created, proceed to design the blueprint, set permissions, and publish the orchestration.

Step 2: Code client scripts

Before scripting, select a website or application from which you’d like to receive the data. We’ve used openweathermap.org’s API in the sample code.
  1. Create a new script and enter a name—Weather update.
  2. Choose Booking Request Orchestration  in the Form  dropdown.
  3. Choose Add new card  as the Execution Location to execute the script when a new card is added.
  4. Choose onChange as the Execution Trigger to allow the script to display the weather forecast when the destination is chosen. On selecting this option, a Fields dropdown will be displayed in the right panel, where you can choose the fields whose update must trigger the script.
  5. Copy paste the below script into your script editor and replace the parameter names.
    1. You can use the ? Icon at the top-right corner of the script editor to refer to parameter names.
  6. Once the script is ready, Publish it. 
Sample Script

async function onChange(forpage,oldVal,newVal,executeOnLoad){
    if(executeOnLoad){
        return;
    }
var weatherdata = ZDK.HTTP.GET(' https://api.openweathermap.org/data/2.5/weather?q='  + newVal.display_name + ',US&APPID=86ed5346f446a2975cb8f16e9eec2417');
 
    var msg = weatherdata.weather[0].description;
    current.Job.setValue(current.Layout.Fields.<select-Destination-weather-parameter-here>.id, msg);
    var temp = weatherdata.main.temp - 270;
    var str_a = temp.toString();
    var result = Number(str_a.slice(0, 5));
    var tempmsg = result + " Degree Celsius";
    current.Job.setValue(current.Layout.Fields.<select-Destination-temperature-parameter-here>.id, tempmsg);
}


Step 3: Add card

Once the form, blueprint, and client scripts are ready, we can test the script by creating a new card.
  1. Navigate to Cards and click Add Card .
  2. Select Booking Request Orchestration  from the Form dropdown.
  3. Enter the travel destination.
    1. The destination’s weather and temperature gets displayed automatically.



      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit

                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsFormstack alternativeEncrypted Forms

                              Wufoo alternativeSecure Forms

                              WCAG



                                        Create. Review. Publish.

                                        Write, edit, collaborate on, and publish documents to different content management platforms.

                                        Get Started Now







                                                          You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                              Manage your brands on social media


                                                                • Desk Community Learning Series


                                                                • Digest


                                                                • Functions


                                                                • Meetups


                                                                • Kbase


                                                                • Resources


                                                                • Glossary


                                                                • Desk Marketplace


                                                                • MVP Corner


                                                                • Word of the Day


                                                                • Ask the Experts


                                                                  Zoho Sheet Resources

                                                                   

                                                                      Zoho Forms Resources


                                                                        Secure your business
                                                                        communication with Zoho Mail


                                                                        Mail on the move with
                                                                        Zoho Mail mobile application

                                                                          Stay on top of your schedule
                                                                          at all times


                                                                          Carry your calendar with you
                                                                          Anytime, anywhere




                                                                                Zoho Sign Resources

                                                                                  Sign, Paperless!

                                                                                  Sign and send business documents on the go!

                                                                                  Get Started Now




                                                                                          Zoho TeamInbox Resources





                                                                                                    Zoho DataPrep Demo

                                                                                                    Get a personalized demo or POC

                                                                                                    REGISTER NOW


                                                                                                      Design. Discuss. Deliver.

                                                                                                      Create visually engaging stories with Zoho Show.

                                                                                                      Get Started Now









                                                                                                                          • Related Articles

                                                                                                                          • Manage Client Scripts

                                                                                                                            Client Scripts are used to incorporate additional validations to business data while they are recorded in Qntrl. In client scripts, you can code using JavaScript and run the code on the end-user’s browser while they are creating a new card or ...
                                                                                                                          • Business case 1: Use client scripts to perform mathematical calculations and validations on data

                                                                                                                            While designing forms to replicate finance related documents like purchase order, invoice, or reimbursement bills, our workflows might require the calculation of total cost or sum of expenses incurred. To automate such mathematical calculations and ...
                                                                                                                          • Business case 2: Use client scripts to auto-populate fields based on user input

                                                                                                                            While designing forms, we would sometimes require to display different sets of fields for different user responses. Such automatic field population can be handled using client scripts.   Business Scenario Helen creates a sign-up form for her product ...
                                                                                                                          • Qntrl Marketplace - An Overview

                                                                                                                            Qntrl Marketplace is an online store with solutions for specific business requirements while working with Qntrl. This is the perfect platform to search for any Qntrl extensions or showcase the extension you have built, which extends the capabilities ...
                                                                                                                          • Use case for Bridge: Connect with remote databases using Bridge

                                                                                                                            Most organizations secure their remote databases using firewalls. If you are looking for a way to navigate these firewalls to access remote databases, Bridge can be of help. Let us try to solve a real-time business case where bridge is used to access ...
                                                                                                                            Wherever you are is as good as
                                                                                                                            your workplace

                                                                                                                              Resources

                                                                                                                              Videos

                                                                                                                              Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                              eBooks

                                                                                                                              Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                              Webinars

                                                                                                                              Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                              CRM Tips

                                                                                                                              Make the most of Zoho CRM with these useful tips.



                                                                                                                                Zoho Show Resources