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.
This script allows you to look up previous entries in a given field, say an email address, customer number, or other unique value, and disqualify respondents if they have already recorded a response.
For the purposes of this example, we used an email field to check for duplicates and disqualify accordingly. You can use any textbox field that you'd like as long as you're using a textbox question type or validated textbox.
On a page that follows the email textbox, add a Custom Script action and paste the below script. Modify the script with your question ID, survey ID, and disqualification message.
Reorder the Custom Script action to the top of the page. This action MUST be at the top of the page.
questionID = 2
value = getvalue(qid)
surveyID = 4516524
message = "Sorry, you have already registered using this email address."
next_pageID = 5
filter = "&filter[field][0]=[question(".. qid ..")]&filter[operator][0]==&filter[value][0]=".. value .."&filter[field][1]=status&filter[operator][1]==&filter[value][1]=Complete"
api = list(sid,1,1,filter)
if(api['total_count'] > 0) then
disqualify(message)
else
jumptopage(next_pageID)
end
Required Customizations
In the script above you will need to customize specific variables. There are four variables that are required to be changed to apply this code to your survey.
questionID - This is question ID of the text field against which you'd like the script to check for duplicate entries.
surveyID - This variable indicates the Survey ID of the survey. You will need to change this survey ID anytime you add it to a new survey.
message - This variable is the disqualify message that is displayed to disqualified respondents.
next_pageID - This is the page to jump to if respondent is not disqualified.