GetModelResponses
Converts response data from one or more questions in the current model into either CSV, XML or JSON data.
Syntax
GetModelResponses( FormatType, KeywordList, KeywordListOption, DataOnlyFlag, KeyValueSeparator, KeyValuePairSeparator, RowSeparator );
Parameters
Parameter Name | Type | Description | Optional? | Default Value |
---|---|---|---|---|
FormatType | Integer | Identifies the format in which you want to save the response data. Set to 1 for CSV, 2 for XML, and 3 for JSON. | No | n/a |
KeywordList | String | A comma-separated list of question keywords in the selected form. The listed keywords will either be included in, or excluded from your saved data depending on the value you choose for KeywordListOption. | No | n/a |
KeywordListOption | Integer | Determines if the questions picked for the KeywordList argument will be the ones included in your stored data, or those excluded from it. Use 1 to include the listed keywords, and 2 to exclude them. Any keywords you have not listed will be either excluded or included, respectively. | No | n/a |
DataOnlyFlag | Boolean | Determines whether the resulting data should exclude certain non-essential details about the specified questions. | Yes | 0/False |
KeyValueSeparator | String | The single alphanumeric character that separates the two parts of each key value pair in the returned data. This parameter has no effect if DataOnlyFlag is set to True, because none of the stripped-down values returned in that case take the form of a key value pair. | Yes | = |
KeyValuePairSeparator | String | The single character that separates the fields (including key value pairs) in your returned question data. | Yes | , |
RowSeparator | String | The single character that separates rows in the returned data. | Yes | | |
Output
If successful, the function will return a string containing the specified response data in the requested format.
Use Case
A market research company has created a comprehensive questionnaire to gather data on the spending habits of shoppers at a particular supermarket. The questionnaire consists of several pages, each of which contains questions about one aspect of the customer's shopping trends.
At the end of the questionnaire, the customer will be asked to click a button that will submit their responses, storing them in a database for later analysis. To accomplish this, a complete set of questionnaire data is collected using the following expression:
ResponseSubmissions:= GetModelResponses( 1, "", 2, 1);
The arguments in the expression above have the following effects:
- FormatType is set to 1, so the data is returned in CSV format.
- KeywordList is empty, and KeywordListOption is set to 2, meaning that no question keywords are excluded.
- DataOnlyFlag is set to 1 (True), so a limited set of response data returned by the expression. Due to the number of questions in the full questionnaire, setting this parameter to False would return a vast amount of unnecessary data.
The resulting CSV is saved to the ResponseSubmissions variable. An example of the data saved by this expression is as follows:
CustSurname, Smith, 1, 1| CustForenames, John, 1, 1| CustDOB, 21/05/1978, 1, 1| CustPostcode, TS1 8TV, 1, 1| CustPhone, 01234 567890, 1, 1| WeeklyBudget, 150, 1, 1| FamilyMemberCount, 3, 1, 1| AgeOfYoungest, 8, 1, 1| AgeOfOldest, 42, 1, 1