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 the list of responses for the given survey. This is equivalent to a get list on the SurveyResponse object via the RestAPI. To learn more visit the SurveyResponse API Object documentation.

Parameters*DescriptionRequired
surveyIDthe surveyIDtrue
pagethe page of the results to returnfalse (defaults to 1)
countperpagethe number of results per page to returnfalse (defaults to 50)
filterstringthe filter to apply to the results returned (To learn more about paging results and filtering visit our Filtering documentation for the Rest API.)false (defaults to null)

*Provide parameters in the above order.

If you wish to output the list function to the page, use the lprint function for best results.

Example

In this example there are two surveys: Survey A and Survey B. Both surveys request the student ID number of the respondent. Survey B uses this function to check if the entered survey ID has been previously recorded on survey A and populates the survey question "Has survey A been completed?" on the second page of survey B.

See it in action (make sure to leave enough time after your response to survey A for your first response to process):

id = 2 --2 is the id of the unique field
student = getvalue(id) --defines student as the ID

surveyA = 646222

--check if the student completed survey A
status = list(surveyA,1,1,'&filter[field][0]=[question(2)]&filter[operator][0]==&filter[value][0]='..student)

--set flag for whether or not Survey A has been completed
flag = 3 --3 is the ID of the completed question

if count(status['data']) == 0 then
	setvalue(flag,'No')
else
	setvalue(flag,'Yes')
end

See also the following working examples for use of this function: