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.
Add a MaxDiff question to the first page in your survey.
Create the follow-up text elements or questions that you would like to conditionally show based on the highest ranked attributes in the MaxDiff Question. In our example, we have twelve text/instruction elements that display the attribute title: Humor, Strength, Attractiveness, Beauty, Compassion, Love, Kindness, Integrity, Empathy, Ambition, Passion, and Honesty.
Make note of the question IDs of your corresponding text elements/questions. Question IDs are available to be displayed on the Build tab. If you don't see your question IDs, check out our Customize Survey Builder Tutorial.
Add a Custom Script action on a subsequent page and copy and paste the below script and make the required customizations listed below.
-- SHOW TEXT/QUESTIONS BASED ON BEST RANKED FROM MAXDIFF
maxdiff = 2
ids = {6,7,9,10,11,13,14,15,16,17,18,19}
attributes = {[6]='Humor',[7]='Strength',[9]='Attractiveness',[10]='Beauty',[11]='Compassion',[13]='Love',[14]='Kindness',[15]='Integrity',[16]='Empathy',[17]='Ambition',[18]='Passion',[19]='Honesty'}
-- HIDE ALL TEXT/QUESTIONS
for key,id in ipairs(ids) do
hidequestion(id, true)
end
-- GET THE ARRAY OF MAXDIFF RANKINGS
data = getvalue(maxdiff)
-- CREATE NEW ARRAY OF BEST RANKINGS
best = {}
for set,setdata in pairs(data) do
best[set] = setdata['best']
end
-- LOOP THROUGH ATTRIBUTES ARRAY AND SET THE QIDs TO SHOW
for key,value in pairs (attributes) do
if (in_array(value,best)) then
hidequestion(key, false)
end
end
Required Customizations
maxdiff - This is the MaxDiff question ID.
ids - This is a comma separated list of the ID for the questions or text elements that you wish to show/hide based on the MaxDiff best values.
attributes - This is an array of the IDs for the questions or text elements that you wish to show/hide and the corresponding attribute value.