sgapiQuestionsAnsweredOnPage(%%pageID,%%options)

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 returns a count of answered questions on a given page. Use %%options to specify question type. %%page should be the page sku/ID (not the page number).

Possible Values for %%options*
RANK (Evaluates Drag & Drop and Table Rank questions)
RADIO (Evaluates Multiple Choice and Likert Scale questions)
CHECKBOX (Evaluates Checkbox questions)
TEXTBOX (Evaluates all Short Text questions, including number, email, percent, date)
MULTI_TEXTBOX (Evaluates List of Textboxes)
TABLE (Evaluates List of Dropdown Menus, Star Ranking, Multiple Choice Table, Table of Checkboxes, Table of Textboxes and Table of Dropdown Menus)
GROUP (Evaluates Custom Group and Contact Group questions)
MENU (Evaluates Dropdown Menu questions)
MENU (Evaluates Dropdown Menu questions)
MENU (Evaluates Dropdown Menu questions)
CONT_SUM (Evaluates Continuous Sum Questions)
*%%options values can be specified as a comma separated string.

Examples

In this example, we flag the survey as 'Complete' if at least 4 of the radio and checkbox questions on the first page have been answered.

%%options = "RADIO,CHECKBOX";
%%numberAnswered = sgapiQuestionsAnsweredOnPage(1,%%options);
if (%%numberAnswered >= 4) sgapiSubmitSurveyComplete();

In this example, we output each of the question types for %% options.

%%radio = sgapiQuestionsAnsweredOnPage(1,'RADIO'); 
%%rank = sgapiQuestionsAnsweredOnPage(1,'RANK'); 
%%checkbox = sgapiQuestionsAnsweredOnPage(1,'CHECKBOX'); 
%%textbox = sgapiQuestionsAnsweredOnPage(1,'TEXTBOX'); 
%%multi = sgapiQuestionsAnsweredOnPage(1,'MULTI_TEXTBOX'); 
%%table = sgapiQuestionsAnsweredOnPage(1,'TABLE'); 
%%group = sgapiQuestionsAnsweredOnPage(1,'GROUP'); 
%%menu = sgapiQuestionsAnsweredOnPage(1,'MENU'); 
%%contsum = sgapiQuestionsAnsweredOnPage(1,'CONT_SUM'); 

%%output .= 'RADIO: '.%%radio;
%%output .= 'RANK: '.%%rank;
%%output .= 'CHECKBOX: '.%%checkbox;
%%output .= 'TEXTBOX: '.%%textbox;
%%output .= 'MULTI_TEXTBOX: '.%%multi;
%%output .= 'TABLE: '.%%table;
%%output .= 'GROUP: '.%%group;
%%output .= 'MENU: '.%%menu;
%%output .= 'CONT_SUM: '.%%contsum;