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 adds a table to the given PDF.

See this function and other PDF functions in action in an example survey.

OR

Add a survey with a script with this function and otherPDF functions to your account.

For more info on PHP PDF Creation visit: https://github.com/rospdf/pdf-php/blob/master/readme.pdf

Parameters*
Description
Required
pdf
The title of the PDF you are creating.
true
dataThe array of data to include in the table.
false
columnsThe array of column headers.
false
titleThe table title.
false
optionsAn array of possible options (see PHP PDF Creation documentation for options).
false

*Provide parameters in the above order.

Example

The below script creates and builds a PDF object, outputs it and adds it as an attachment to a send email action. In the highlighted portions of the script, we the table data and columns and add it to the PDF using tablepdf.

pdf = "Example PDF"
text = "Text to include in PDF"
size = 14
options = {['spacing'] = 1.5}
table = {row1={1,2,3,4}, row2={5,6,7,8}, row3={9,10,11,12}}
columns = {'Column A','Column B','Column C','Column D'}

newpdf(pdf,'letter','portrait')
setfontpdf(pdf,'courier')
setcolorpdf(pdf,0,1,1)
imagepdf(pdf,'https://surveygizmolibrary.s3.amazonaws.com/library/160589/surveysoftwareapi.png') 
textpdf(pdf,text,size,options)
tablepdf(pdf,table,columns,'Table Title')

formattedpdf = pdfoutput(pdf)

attachment = {}

attachment['example.pdf'] = formattedpdf

--Attach to existing send email action (ID 30)
setquestionproperty(30,"email_attachments",attachment)

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