Important Update to Custom Scripting
SurveyGizmo's Legacy Custom Scripting Language is being sunsetted in favor of the LUA programming language. See our new Lua Scripting Resources to get started using Lua in your Custom Script Actions.
For the foreseeable future, Custom Scripts using the Legacy Custom Scripting Language will continue to operate without issue; though it is a good idea to get started scripting with Lua. We will communicate sunset plans as they are formulated.
This function populates the response value of the given question.
For hidden value, textbox, essay, radio button, drop-down menu, slider and image choice %%value is defined as a "string."
For checkbox and Drag & Drop %%value must be specified as an array.
To set the value of a list of dropdowns, radio button table, and checkbox table %%questionID should be specified as the ID of the table's row.
The following example will set the value of a question to be "yes." The question type could be text, essay, radio button, dropdown menu, or a hidden value action. If it is a radio button or dropdown, you need to make sure that it has the corresponding reporting value.
Next let's set the value of a checkbox question. Let's say our checkbox question has reporting values "a", "b" and "c." Here, we tell our script to check the "a" and "c" options.
%%options = array("a","c"); sgapiSetValue(2,%%options);
For Drag & Drop Ranking questions you'll need to specify an array using the option skus like so:
sgapiSetValue(2,array('10001' => 4, '10002' => 3, '10003' => 2, '10004' => 1));