Piping: Radio Button Grid to Radio Button Grid

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.

In this example, we are going to only show the rows in the target radio button grid questions for which any of a specified set of column answers were checked in the source Radio Button Grid.

For this to work, the target Grid question must be set up with row titles as from the source Radio Button Grid question.

Note: This script can work with conditional piping from a Radio Button Grid question to any Grid question, as all grid questions in SurveyGizmo have the same structure, with each row corresponding to a separate question id.

Example survey (4th to 5th page): http://www.surveygizmo.com/s3/2158494/Radiobutton-Grid-to-Radiobutton-Grid-conditional-piping


Want to download this survey to your account so you can play with it? Just click here.

Estimated implementation and testing time: 5-10 minutes

This script uses the following custom scripting functions:

  • sgapiArray_Flip
  • sgapiGetTableQuestionTitles
  • sgapiGetValue
  • sgapiHideQuestion
  • sgapiIn_Array
  • sgapiCount
  • sgapiJumpToPage

The Script

The script below requires the for us to plugin the question id of the source Radio Button Grid question, the question id of the target radio button grid question, the id of the next page to jump to (should there be nothing to display on the page with the target question), and an array with the comma-separated, single quote marks enclosed names for each of the options from the radio button grid columns you would like to be in the qualifying set of answers to have that row displayed in the target Radio Button Grid question.

%%source_id = 2;
%%target_id = 36;
%%next_page_id = 2;
%%target_options = array('Already have or do','Will do later this year'); //this is the array of options which qualify that row for being shown in the subsequent grid if one of them is ticked

%%radiotable1 = sgapiArray_Flip(sgapiGetTableQuestionTitles(%%source_id)); //row title => id
%%radiotable2 = sgapiArray_Flip(sgapiGetTableQuestionTitles(%%target_id)); //row title => id

%%hidden_rows = 0;

foreach(%%radiotable1 as %%title => %%id) { //loop through the checkbox grid question rows

   %%row_value = sgapiGetValue(%%id); //get the values, each row is like a separate checkbox question
   %%hidden_rows += 1;

   sgapiHideQuestion(%%radiotable2["%%title"], true); //initially hide the corresponding row from the radio button grid
      if(sgapiIn_Array(%%row_value, %%target_options)){ // if the value checked is in the target options array, then unhide the corresponding row in the radio grid
         sgapiHideQuestion(%%radiotable2["%%title"], false); //initially hide the corresponding row from the radio button grid
         %%hidden_rows -= 1;


if(%%hidden_rows == sgapiCount(%%radiotable2)) {



In the script above you will need to customize variables highlighted in yellow in order to make the script work the way you'd like.

Required Customizations

%%source_id1 - This variable will indicate the question ID of the source Radiobutton Grid question.

%%target_id - This variable will indicate the question ID of the target grid question.

%%next_page_id - The page to jump to if no options are selected in the Radiobutton Grid question such that the corresponding rows are displayed in the target grid question (and therefore this question has no rows so the page should be skipped).

%%target_options - The array of options ticked per row which you wish to qualify that row for being displayed in the target grid question, formatted as you see in the script, encased in single or double quotes and comma separated with no comma after the last one.

Scripting and Other Custom Solutions

We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.

If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your customization. Beyond this, you might want to consult with someone on our Programming Services Team; these folks might have the scripting chops to help you to achieve what you are looking for!