Text piping allows you to dynamically insert text into questions and answers based on previous answers. Piped text can be used to personalize a survey (for example, you can address a respondent by their name) or simply to avoid re-entering already known information. In follow-up questions, piped text can be used to ask a respondent to indicate reasons behind their answer or elaborate on a brief response with further comments or details. For instance, if respondents should fill out an employment history form, you can ask them to list their previous and current employers briefly, and then you can use piped text to generate detail forms for each employer.
Implement Text Piping
To implement text piping, assign the same value to the
valueName property of questions that should share data. In this demo, the employment history form contains two questions of the Dynamic Matrix and Dynamic Panel types. Respondents enter a list of employer names into the matrix and details about each employer into multiple panels. Together, Dynamic Matrix and Dynamic Panel produce an
employees array of objects. The matrix supplies the
employee-name field values; the panel supplies the remaining field values. Once associated via
valueName, two questions can reference each other's values. For example, values from the matrix can be displayed in panel headers, as shown in this demo.
Pipe Text Between Incompatible Question Types
Dynamic Matrix and Dynamic Panel are compatible because they both produce arrays of objects when they are used as standalone questions. In some instances, you need to pipe text between questions that produce results in different formats and as such are incompatible. For example, the Checkbox question type produces an array of primitive values, and a primitive value cannot be merged with an object. To force a Checkbox question to produce an array of objects, specify the
valuePropertyName property with a field name that should store question values. This field name can be used to pipe the question values to other associated questions.
In this demo, the second survey page asks respondents to tell about their language skills. Respondents should select languages they speak from a Checkbox question. For each selected language, a Dynamic Panel question generates a detail panel. The two questions are associated via
valueName and the Checkbox question produces an array of objects. The
language object field stores the selected language. This field is used to reference languages in panel headers.