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 function returns a count of answered questions on a given page. 

Parameters*
Description
Required
Default
pageID
the ID of the page
true

typethe question type
falseDefaults to all questions on the page

*Provide parameters in the above order.

Type Possible Values*Corresponding Survey Question
CASCADING_DROPDOWNCascading Dropdown Menu
CHECKBOXCheckboxes
CONJOINT_NEWChoice-based Conjoint
CONT_SUMContinuous Sum
ESSAYEssay/Long Answer
FILEFile Upload
GROUPContact Form and Custom Group (Groups are evaluated by subquestion such that each subquestion that is answered increments the return by 1.)
HEATMAPImage Heatmap
IMAGE_SELECTImage Select (Single and Multi)
MATRIXCustom Table (Custom Tables are evaluated by subquestion such that each row and subquestion combination increments the return by 1.))
MAXDIFFMax Diff
MENUDropdown Menu
MULTI_SLIDERSlider List
MULTI_TEXTBOXTextbox List
NPS®Net Promoter Score®
RADIORadio Buttons, Likert (Rating)
RANKDrag & Drop and Ranking Grid
REACTIONAudio and Video Sentiment
SIGNATURESignature
SLIDERSlider
TABLEGrid question types (Semantic Diff, Star Rating Grid, Radio Button Grid, Dropdown Menu List, Checkbox Grid, All Card Sorts, Dropdown Menu Grid ). Tables are evaluated by row/subquestion such that each row that is answered increments the return by 1.
TEXTBOXText fields including (textbox, number, percent, email, and date)
TEXTHIGHLIGHTERText Highlighter

*multiple type values can be specified as a comma-separated string.

Examples

In this example, we flag the survey as 'Complete' if at least 4 of the radio and checkbox questions on the first page have been answered.

questiontypes = "RADIO,CHECKBOX"
numberAnswered = questionsansweredonpage(1,questiontypes)
if (numberAnswered >= 4) 
  then submitsurveycomplete()
end

In this example, we output each of the question types.

cascadingdd = questionsansweredonpage(1,'CASCADING_DROPDOWN')
checkbox = questionsansweredonpage(1,'CHECKBOX')
conjoint = questionsansweredonpage(2,"CONJOINT_NEW")
contsum = questionsansweredonpage(1,'CONT_SUM') 
essay = questionsansweredonpage(1,'ESSAY')
file = questionsansweredonpage(1,'FILE')
group = questionsansweredonpage(1,'GROUP')
heatmap = questionsansweredonpage(1,'HEATMAP')
imageselect = questionsansweredonpage(1,'IMAGE_SELECT')
matrix = questionsansweredonpage(1,'MATRIX')
maxdiff = questionsansweredonpage(3,'MAXDIFF')
menu = questionsansweredonpage(1,'MENU')
multislider = questionsansweredonpage(1,'MULTI_SLIDER')
multitext = questionsansweredonpage(1,'MULTI_TEXTBOX')
nps = questionsansweredonpage(1,'NPS')
radio = questionsansweredonpage(1,'RADIO')
rank = questionsansweredonpage(1,'RANK')
reaction = questionsansweredonpage(1,'REACTION')
signature = questionsansweredonpage(1,'SIGNATURE')
slider = questionsansweredonpage(1,'SLIDER')
table = questionsansweredonpage(1,'TABLE')
textbox = questionsansweredonpage(1,'TEXTBOX')
texthighlighter = questionsansweredonpage(1,'TEXTHIGHLIGHTER')


print(cascadingdd)
print(checkbox)
print(conjoint)
print(contsum)
print(essay)
print(file)
print(group)
print(heatmap)
print(imageselect)
print(matrix)
print(maxdiff)
print(menu)
print(multislider)
print(multitext)
print(nps)
print(radio)
print(rank)
print(reaction)
print(signature)
print(slider)
print(table)
print(textbox)
print(texthighlighter)

Net Promoter®, NPS®, NPS Prism®, and the NPS-related emoticons are registered trademarks of Bain & Company, Inc., Satmetrix Systems, Inc., and Fred Reichheld. Net Promoter Score℠ and Net Promoter System℠ are service marks of Bain & Company, Inc., Satmetrix Systems, Inc., and Fred Reichheld.