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")]

This script pipes from a Radio Button Grid to a Checkbox question which is not supported with the built-in piping options. This script will work to pipe (conditionally or unconditionally) from a Radio Button Grid question into any question with a list of answer options (e.g. Textbox List, Radio Button, Checkbox, Multi-Slider, Dropdown Menu, etc.)

In this example script, we conditionally pipe rows of a Radio Button Grid with selected answers of either 4 or 5 and then filter the list of options in the subsequent Checkbox question accordingly. For this to work, the target question must be set up with answer options identical to the row headers of the source Radio Button question. Built-in piping should be turned off.

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

The script below requires us to plugin the questionIDs of the source Radio Buttons Grid question and the target Checkbox question, the ID of the next page to jump to (should there be nothing to display on the page with the target question), and optionally a value of true or false depending on if you have an exclusive 'Not Applicable' / 'None of the Above' type option in your target Checkbox question. 

sourceID = 3 --radiogrid ID
targetID = 22 --checkbox ID

-- set this to true if there is a not applicable type option in the checkbox list and false if not
na_present = true 
next_pageID = 2

table = gettablequestiontitles(sourceID) --id => title
checkboxes = getquestionoptions(targetID)

hidden_options = 0
for id,title in pairs(table) do
   
   value = getvalue(id)
   if (value < "4") then  --if the answer neither 4 or 5

      removeoption(targetID, title)
      hidden_options = hidden_options + 1
   
   end

end
if(((count(checkboxes) == hidden_options) and (na_present == false)) or
(((count(checkboxes) - 1) == hidden_options) and (na_present == true))) then

  jumptopage(next_pageID)

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 variable will indicate the question ID of the source Radio Button Grid question.

targetID - This variable will indicate the question ID of the target Checkbox list / any list of answers type question.

na_present - Set to 'true' if you have an exclusive answer option  (like 'None of the above', etc) which you would like to appear in the target Checkbox question irrespective of what is chosen in the source question.

next_pageID - The page to jump to if no options are selected in the source question which corresponds with answer options in the target question.