sgapiSetQuestionProperty(%%questionID, %%property, %%value)

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 

  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. The exact date on this is to be determined; we will send notifications well ahead of time.

This function sets the given property to the given value for the given question.

Possible Properties Values
exclude_number boolean
labels_right boolean
orientation VERT/HORZ
question_description_above boolean
custom_css Template CSS hook name
required boolean
force_percent boolean
force_currency boolean
min_number value
max_number value
min_answers_per_row value
minimum_response, value value
defaulttext text/reporting value
max_total value
max_total_noshow boolean
email_attachments value
xnumber value


The below script sets the required property for question ID 10.

%%questionID = 10;
%%property = 'required';

sgapiSetQuestionProperty(%%questionID, %%property, %%value);

This script utliizes the sgapiRand function in combination with the sgapiSetQuestionProperty function to randomize the orientation of the target question.

Check it out in an Example Survey

%%questionID = 2;
%%property = "orientation";
%%random = sgapiRand(0,1);

if (%%random == 0) {
    %%value = "VERT";
    %%value = "HORZ";


Using the "email_attachments" property you can attach a custom-built PDF to an existing send email action. In this example we set the "email_attachments" property of the send email action (ID 3)equal to the %%attachment custom PDF that we created.

%%pdf = "Example PDF";
%%text = "Hello World!";
%%size = 14;
%%options = array('spacing' => 1.5);
%%table = array( array(1,2,3,4), array(5,6,7,8), array (9,10,11,12) );
%%columns = array('Column A','Column B','Column C','Column D');

sgapiTablePDF(%%pdf,%%table,%%columns,'Table Title');

%%formattedpdf = sgapiPDFOutput(%%pdf);

%%attachment['example.pdf'] = %%formattedpdf;