Important Update to Custom Scripting
SurveyGizmo's CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!
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. The exact date on this is to be determined; we will send notifications well ahead of time.
This function returns the answer option title of the selected answer option (or null, if not answered). For single-select questions, a single value is returned. Multi-select and matrix questions will return an array.
Using the %%language parameter you can return the title in the given language. The values are the languages available in the translation menu. %%language must be title case.
Examples
In this example, we return the answer option label(s) of a likert scale question using sgapiGetValue() and sgapiPrint_R().
Check it out in an Example Survey
%%output .= sgapiGetValueLabel(2);
Take a Likert Scale question with the following labels and reporting values:
- Very Dissatisfied | 1
- Dissatisified | 2
- Neutral | 3
- Satisfied | 4
- Very Satisfied | 5
The output would be: Very Satisfied
In this example, the following code will output the option title in the language of your choice.
//single select (hard coded) to pull Spanish %%source_Question_Id = 5; %%output = sgapiGetValueLabel(%%source_Question_Id, 'Spanish');
%%source_Question_Id = 5: This will be your source question. Just replace 5 with your Question ID.
To specify a language, replace Spanish (within the single quotes) to your preferred language.