SurveyGizmo's CustomScript Action now supports the LUA programming language.
Legacy Custom Scripting Language Deprecation Plans
New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
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.
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.
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.
In this scenario, our custom script filters the grid rows of a target question based on any corresponding, selected options in the source checkbox question. Normally, it would be fine to use standard piping, but here the source question contains options for both Sega and Nintendo classic video games, but in the target question, we only want to ask about Nintendo video games which respondents have played.
Because all grid questions are set up with each row given a separate questionID we can use it to conditionally pipe from a checkbox question to any grid question (i.e. radio button, textbox, dropdown menu grid).
For this to work, the target question must be set up with the Nintendo classic games row titles from the source question as grid rows, with automatic piping turned off.
The script below requires us to plug in the id of the source checkbox question, the id of the target grid question and the page id or the page to jump to in case there are no rows left to display in the target question due to the filtering.
--filter grid rows by checkbox question selections
sourceID = 18 --checkbox questionID
targetID = 34 --grid questionID
next_pageID = 3 --pageID of the next page (used to jump to in case there are no rows to show in the grid)
source_values = getvalue(sourceID) --array of source options checked
target_question_titles = gettablequestiontitles(targetID) --array of grid row titles
hidden_qids = 0
for key,title in pairs(target_question_titles) do
hidequestion(key, false)
if(not(in_array(title,source_values))) then
hidequestion(key, true)
hidden_qids = hidden_qids + 1
end
end
--if there are no options left to show, skip to the next page
if(count(target_question_titles) == hidden_qids) 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 Checkbox question.
targetID - This variable will indicate the question ID of the target grid question.
next_pageID - The page to jump to if no options are selected in the checkbox question that corresponds to the rows titles of the target grid question.