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.
This example script can works for conditional piping from a Radio Button Grid question to any Grid question, as all grid questions in Alchemer have the same structure, with each row corresponding to a separate question id.
In this example script, we show the rows in the target Radio Button Grid questions for which any of a specified set of column answers were checked in the source Radio Button Grid.
For this to work, the target Grid question must be set up with row titles identical to the source Radio Button Grid question.
The script below requires us to plugin the questionID of the source Radio Button Grid question, the questionID of the target Radio Button Grid question, the ID of the next page to jump to (should there be nothing to display on the page with the target question), and an array with the comma-separated, single-quote enclosed names for each of the options from the Radio Button Grid columns you would like to be in the qualifying set of answers to have that row displayed in the target Radio Button Grid question.
sourceID = 2
targetID = 72
next_pageID = 2
--an array of selected options which qualify that row to show in the subsequent grid
target_options = {'Already have or do','Will do later this year'}
radiotable1 = array_flip(gettablequestiontitles(sourceID)) --row title => id
radiotable2 = array_flip(gettablequestiontitles(targetID)) --row title => id
hidden_rows = 0
for title,id in pairs (radiotable1) do --loop through the first question grid rows
--get the values, each row is like a separate question
row_value = getvalue(id)
hidden_rows = hidden_rows + 1
--initially hide the corresponding row from the second radio button grid
hidequestion(radiotable2[title], true)
--if the value checked is in the target options array, then unhide the corresponding row
if in_array(row_value, target_options) then
--unhide the corresponding row from the radio button grid
hidequestion(radiotable2[title], false)
hidden_rows = hidden_rows - 1
end
end
-- jump to specified page if now rows are shown
if(hidden_rows == count(radiotable2)) 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 grid question.
next_pageID - The page to jump to if no options are selected in the Radio Button Grid question such that the corresponding rows are displayed in the target grid question (and therefore this question has no rows so the page should be skipped).
target_options - The array of options ticked per row which you wish to qualify that row for being displayed in the target grid question, formatted as you see in the script, encased in single or double quotes and comma separated with no comma after the last one.