Lua Scripting Resources

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language.


Legacy Custom Scripting Language Deprecation Plans 

  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. Read-only scripts will continue to function; you will just be prevented from editing. The exact date on this is to be determined; we will send notifications well ahead of time.


 Go to our Legacy Scripting Documentation.

While SurveyGizmo is one of the most flexible survey tools around, we get requests for customizations that are not available out of the box. This is where JavaScript and Custom Scripting can save the day. If you have scripting chops you can use the JavaScript action or the Custom Scripting action to achieve the survey of your dreams.


[article("bodfy")]

The Continuous Sum question is a very popular question, particularly with our market researchers. Often survey designers are looking to make sure that the continuous sum total matches another value that the respondent entered. In this tutorial, we'll cover a script for dynamically defining the maximum total value for a continuous sum question from an answer to a previous question.

See the script in action in an example survey!

OR

Add a survey with this script and setup to your account.

Features and functions used in this script:

The Script

This script will set the Max Total property of a continuous sum question to the value entered in a specified textbox list row, textbox, or slider.

--Setting the max value of a continuous sum question dynamically
sourceID = 2 -- textbox list source QID
targetID = 3 --contiunuous sum target QID
next_pageID = 2 -- pageid of the next page to jump to if the repondent has ekyed in zero hours
source_option_sku = 10002 -- option sku for the TV hours option from textbox list



source_value = getvalue(sourceID) --values of source textbox list q
property = 'max_total'
if(isarray(source_value)) then

   setquestionproperty(targetID, property, source_value[source_option_sku])
   if(source_value[source_option_sku] == 0) then

      jumptopage(next_pageID)

   end

else 

   setquestionproperty(targetID, property, source_value)  
   if((source_value == 0)) then

      jumptopage(next_pageID)

   end
end

Required Customizations

In the script above you will need to customize variables highlighted in yellow in order to make the script work in your survey.

sourceID - This is the source question you wish to pull from the set the Continuous Sum question max total.

targetID - The target Continuous sum question whose max total value you wish to set. 

next_pageID - pageID of the next page to jump to if the respondent enters zero in the source.

source_option_sku - If source question is a Textbox List the option SKU for the row you wish to pull from must be specified. Not sure how to find your option SKU? Check out our How To Find IDs document! If your source is a Textbox or Slider question set source_option_sku=0.