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")]

Building and sending attachments with custom content is a very common customization achieved via custom scripting. To learn how to build a PDF file with custom content see our PDF Functions.

The Scripts and Setup

Once you've built your custom content there are two options to send this out via email.

Option 1: Use the emailsend function

Using emailsend you can populate each of the fields for an email including attachments to attach your custom files. This will send an email with your attachments when the script is run.

Features and functions used in this script:

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

newpdf(pdf,'letter','portrait')
setfontpdf(pdf,'courier')
setcolorpdf(pdf,0,0,0)
textpdf(pdf,text,size,options)
tablepdf(pdf,table,columns,'Table Title')

formattedpdf = pdfoutput(pdf)

attachment = {}
attachment['example.pdf'] = formattedpdf

to = getvalue(3)
toname = getvalue(2)
textBody = ''
bcc = ''
htmlBody = "Thank you for completing the survey. Your response is appreciated
We will be in touch shortly!.

 Thanks,
Your Company"

emailsend(to, toname, "your.company@company.com", "Your Company", "Your Assessment Results", textBody, htmlBody, bcc, to, "html", attachment)

Option 2: Use the setquestionproperty function

 A much easier way to achieve this is to use the email_attachment parameter for the setquestionproperty function to attach your custom built file to an existing send email action. 

Features and functions used in this script:

The script for this looks like so:

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

newpdf(pdf,'letter','portrait')
setfontpdf(pdf,'courier')
setcolorpdf(pdf,0,0,0)
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 5)
setquestionproperty(5,"email_attachments",attachment)