Custom Scripts

Custom Script

JavaScript & Deluge snippets :

What are JavaScript/Deluge Snippets?

JavaScript/Deluge snippets are tiny bits of code that can be embedded in surveys to enable complex logic and to optimize the process of collecting user responses. They bring dynamic possibilities to your surveys and can help create an interactive and engaging experience for your respondents.

For example, if a survey question asks "Do you own a car?" and the respondent answers "No," JavaScript/Deluge codes can be used to add skip logic and direct the respondent to the next question that is relevant to non-car owners, rather than showing irrelevant questions about car ownership.

JavaScript/Deluge enables you to customize survey interactions by adding custom logic, conditions, loops, and other features for more flexible surveys. With this tool at your disposal, you can create sophisticated survey designs that keep your respondents engaged by delivering dynamic content tailored to their situations.

Accessibility :

Snippets are accessible to all Pro and Enterprise plan users.

Use cases : 
 
Add logic to questions/answers

Display and answer logic allows you to modify your survey questions, so that respondents only view questions relevant to them. For example, let's say you want to ask people about their favorite ice cream flavor, but only if they like ice cream. You can use JavaScript to automatically skip this question for anyone who answers "No" when asked whether they like ice cream. This is great for keeping surveys short, concise and on topic for each respondent.

Apply Skip Logic to your surveys

When you present a long survey, chances are high that they are being answered by robots or some automated software.You can use JavaScript snippets in conditions and loop the questions to prevent automated answers. For example, you can gather "last name" or repeat any question from the previous page in the middle of the survey. You can then cross-check the answers and draw a conclusion whether the survey is being forged or not.

Snippets in triggering emails

You can use JavaScript/Deluge snippets to trigger emails based on specific answers. When someone answers in a certain way, an email gets sent automatically with customized content around their response, which may include links or other information about related topics or products. Using these snippets in a survey allows you to trigger emails automatically when participants complete the survey.

Javascript snippets as variables 

JavaScript snippets can be used for advanced piping. you can customize questions based on how people answered earlier ones. It's like tailoring the survey to fit each person, making it easier and more comfortable for them to answer.
Suppose you have a survey where respondents are asked to provide their name, gender, and date of birth. Once they provide this information, you use JavaScript to figure out how old they are based on their birthdate. Following that, your age is displayed/used in the next relevant question.


A few key pointers while using JavaScript/Deluge snippets in your surveys
 
  1. You can use JavaScript/Deluge snippets to display/hide the question or to skip the pages based on code (arithmetic operations) result, from previous questions. Only basic codes can be used and executed in a survey.

  2. Built-in variables provided in the insert variable box can be used. All other built-in JavaScript methods are restricted. Only the functions listed below will be allowed.   ( isNaN, isFinite, parseFloat, parseInt, Math, createDate.)
    For example, we can use application.createDate() instead of Date() or this.Date(). Both Date() and this.Date() are restricted.

  3. Variables can only be declared using var/const/let before entering the code.

  4. If the JavaScript snippet code you have entered in the condition is invalid or takes longer time than expected, the condition result will be considered as false.

  5. To ensure security, all responses are treated as String data. If a user intends to utilize a response as an integer, they must employ the "parseInt" function to convert it from a string to an integer. This is crucial, especially for number-type or slider questions, as the response might be employed in conditions or calculations for security purposes.

  6. If restricted keywords are used, an error will be thrown and the logic/condition will not be saved.

    The Following keywords are restricted to be saved :
JavaScript :



 
Deluge:
sendmail
posttochat
zoho
integration
 
  1. If your survey is multilingual, you need to enter the specific language’s translation code to enable the condition or logic within the survey. For example, for the Tamil language "ta" should be given.

  2. If you have added conditions using the Date & Time question, then you have to use the same date format used in the previous question.

  3. You can do sample test while adding conditions to question/pages.To test, enter the code, then click Test with sample data. It will generate the sample data. Click the Run button to view the sample result. You can add code and regenerate or modify the sample data as many times as you want to test.
  1. To track the flow of the code, you can use the log feature provided in the insert variable box. You can view the log along with result of the sample test.

  2.  While using script conditions in URL Parameter, you must enter  the param value inside square brackets. For example, application. survey.urlparam ["userName"] in JavaScript, because special characters are not allowed in the JSON key in dot notation.

  3. To avoid syntax errors, javascript code should contain javascript syntax and it should always end either with semicolon or be properly wrapped inside curly braces.

A sample reference Java script snippet code to achieve a simple arithmetic operation :

The given code combines arithmetic operations and conditional statements to make decisions based on the values of certain variables or expressions.

 

var rating = application.survey.question.C.response + application.survey.question.D.response;

if (application.survey.question.A.response == "Single" || application.survey.question.B.response == 2)

{

    return true;

}

else if (rating > 10)

{

    return true;


 A sample reference Deluge snippet code to achieve a simple condition :

The provided Deluge code snippet demonstrates a simple condition using an if statement.
This code snippet checks a specific response value and returns true if it matches the string 'Single'.

 

 

if(application.get('survey').get('question').get('C').get('response') == 'Single' )

 

{

 

return true;

 

}

 

Read more about built-in Deluge functions here. You can only use text functions, Date- Time functions, Number functions and some Common functions.

 
  1. You can customize the logic conditions in JavaScrip snippets in your questions, answers,skip logic, survey end page and also while triggering emails to respondents.

  2. You can customize the logic conditions in Deluge snippets in survey end page and while triggering emails to respondents.
Display Logic :

To apply logic to a question:  
  1. Hover over the question that you want to apply the logic to, then click .

  2.  Click Display Logic. You can also click the question to edit and select the Display Logic tab.

  3.  Click the dropdown and select the display/hide option for the question.
  4. Always display this question
  5. Never display this question
  6. Display this question only if a certain condition is met
  7. Hide this question only if a certain condition is met

  8.  If you select Display this question only if a certain condition is met, or Hide this question only if a certain condition is met, the Condition section will be displayed.

  9. Select a condition in the Condition List Box.
 

  1. Select a question or custom script (JavaScript snippet) in the If dropdown.
    You can either use Built in Functions or write a simple JavaScript function based on your requirement, to set up a Display logic condition for that particular question.
     

 
 
 
  1. Type in or choose the answer you're looking for in the Operand box.
  1. Click + to add multiple conditions.
Note
Multiple conditions work in a pattern similar to this: (((((C1 and/or C2) and/or C3) and/or C4) and/or C5) and/or ...) where C1, C2, C3, ... are the conditions.
  1. Click X to remove conditions.
  2.  Click And/Or to connect multiple conditions. Click Save.

Answer Logic

To apply a logic condition to an answer choice:
  
  1. Click the question that you want to apply the answer display logic to, and select the Answer Display Logic tab. You could also hover over the question and select Actions > Display Logic to get there.

  2. Click the Add Logic tab.

  3. Choose a display/hide condition from the dropdown list.

  4. Click Select Choice to add the choices you want to display or hide.

  5. Click the If dropdown and select an appropriate option.

  6. Select a condition in the Condition list.


  1. Select a question or custom script (JavaScript snippet) in the If dropdown.
    You can either use Built in Functions or write a simple JavaScript function based on your requirement, to set up a Answer logic condition for that particular question.

 

 

  1. Type in or choose the answer you're looking for in the Operand box.

  2. Click + to add multiple conditions.

  3. Click X to remove conditions.

  4. Click And/Or to connect multiple conditions.

  5. Click Save.

Page Skip Logic

To add a page skip logic:
  
Click Logic at the top-right corner of the page name ribbon.


  1. Click the Page Skip Logic icon.

  2.  Click Add Condition to redirect your respondents to specific pages based on their response.
  1. Select a question or custom script (JavaScript snippet) in the If dropdown. You can either use Built in Funtions or write a simple JavaScript function based on your requirement, to set up a page skip logic condtion to your survey.
 


 
 
 
  1. Select an operand in the second dropdown.

  2. Choose an answer from the Select an option dropdown list.

  3. Select the related action for the answer selected in the skip to dropdown list. You can redirect respondents  to the survey end page or to disqualification page.
  1. Click + to add multiple conditions.
    Note: Multiple conditions work in a pattern similar to this: (((((C1 and/or C2) and/or C3) and/or C4) and/or C5) and/or ...) where C1, C2, C3, ... are conditions.

  2. Select And/Or to connect multiple conditions.

  3. Select Go to next page in the default flow if you want your respondents to move to the next page after they're done with the current page.
  1. Select Survey End Page if you want to send them to the end page of the survey instead of moving them to a specific page.

  2. Select Disqualification Page if you want to send them to a survey disqualification page.

  3. Click Save.
 
Trigger Emails
To set up an automated email to respondents who have given specific answers:

  1. Click the Hub tab and select Triggers.

  2. Click Create in the Trigger Emails section.

  3. Click Add Condition to set a condition to send an email based on the requirement.

  4. You can choose any one of the following options to trigger emails.

    Question : Sending email based on the answer to a particular question.
    Response : Sending email based on the survey completion status based on the responses recieved.

  5.  JavaScript /Deluge Snippet : Send email triggers by enabling programming language codes. You can either use Built-in Functions or write a simple JavaScript /Deluge function based on your requirement.
  1. Click + to add multiple conditions.
 
Note:
Multiple conditions work in a pattern similar to this: (((((C1 and/or C2) and/or C3) and/or C4) and/or C5) and/or ...) where C1, C2, C3, ... are the conditions.
 
  1. Select a question from the If dropdown list.  

  2. Set a condition for the selected question.

  3. In the Operand box, type in the answer for the condition you've set.When the user submits their response, and if the question meets the conditions you've set, an email will be sent to the respondent. You can also apply multiple logic options in an email trigger.

  4. Click Save. 

Survey End Page
  1. To add logic for your survey end page:
      
  2. Click Survey End Page in the Settings tab.

  3. Click Add Logic in the End Page Logic section.

  4. Select a condition in the If list.

  5. Select a question or custom script (JavaScript/Deluge snippet) in the If dropdown. You can either use Built in Functions or write a simple JavaScript/Deluge function based on your requirement, to set up a Survey end page condition for the survey.

  6. Click X to remove conditions.
  1.  Click And/Or to connect multiple conditions.

  2. Click Save.

Advanced piping using Java Script Snippets :

To insert a Javascript Variable:

  1. To add a new question, click the question type you'd like to use on the Survey Builder page, or drag a question from the left pane and drop it in the builder.

  2. Click on the Insert Variable dropdown in the top-right corner and choose Javascript Snippet from the provided list.




  1. Enter the code.Click insert variable(inside one), to use inbuilt functions in code.
  2. Click Test with sample data.
  3. Click the Run tab and check the result.
  4. Click the Save button to save your changes.

To manage edit or delete a javascript variable:

  1. Select the question in the survey in which you want to edit or delete the variable.
  2. Click on the inserted variable
  3. Click to edit the variable.
  4. Make the necessary changes and click Update.
  5. Click to delete the variable.


 



 




 

    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









                                      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

                                            Zoho Desk Resources

                                            • Desk Community Learning Series


                                            • Digest


                                            • Functions


                                            • Meetups


                                            • Kbase


                                            • Resources


                                            • Glossary


                                            • Desk Marketplace


                                            • MVP Corner


                                            • Word of the Day


                                              Zoho Marketing Automation

                                                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 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

                                                                                                        • Custom Report

                                                                                                          You can select questions and create customized reports. These reports can be shared or chosen by filter to show responses for specific questions. To create a custom report: Click Create in the Custom Report section. Enter a name in the Report name ...
                                                                                                        • Custom V​ariables

                                                                                                          Zoho Survey offers the following advanced features that take your surveying experience to a new level. Custom Variables Scoring Invite Reviewer Share Survey Send Copy Transfer Survey Export as PDF Print Survey Using custom variables allows you to ...
                                                                                                        • Custom Field Encryption

                                                                                                          You can now encrypt specific questions and custom variables, and the responses will be encrypted at rest (storage). For encrypted fields, only the equal to, not equal to, answered, and not answered operators will work in the reports filter. This ...
                                                                                                        • How do I set up a custom domain?

                                                                                                          To set up a custom domain, perform the following steps: Sign in to your domain registrar's control panel. Access the DNS Management Settings to change the DNS records. If you can't locate DNS Management, look for options such as Advanced Settings or ...
                                                                                                        • What should I do if my custom domain is not working?

                                                                                                          This can happen when your sub-domain is not mapped with survey.cs.zohohost.com. Please perform the following steps: Sign in to your domain registrar's control panel. Access the DNS Management Settings to change the DNS records. If you can't locate ...
                                                                                                          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