Getting and setting values of profiler variables
This article is for v7.04 of Q_Panel.
To display the current values of profile variables when using a Q_Survey questionnaire as a profiler on Q_Community, code must be added to each question on the questionnaire to get the current value from the Q_Panel database and set this value on the questionnaire being displayed.
Questionnaire settings required
A hidden question is required which contains the external panellist ID required for the API call.
Edit the Questionnaire Settings:
(This script contains the 'Set' functions).
- On the Advanced tab select the Script file field and enter the following file:
(This script contain the 'Get' functions).
Getting the current value from Q_Panel
For each survey question:
1. Click on +Add and select Reference to Question (if there is more than one Reference to Question then make sure the new one comes first).
2. In the Reference to Answer tab enter the name of the function call plus parameters in the Reference field. The function required depends on the type of question:
|Single||fncGetSingleExternal||BaseURL, ExternalID, QuestionLabel|
|Multiple||fncGetMultipleExternal||BaseURL, ExternalID, QuestionLabel|
|Single Grid||fncGetGridSingleExternal||BaseURL, ExternalID, QuestionLabel, Rows|
|Multiple Grid||fncGetGridMultipleExternal||BaseURL, ExternalID, QuestionLabel, Rows|
|Open or Numeric||fncGetCharacterExternal||BaseURL, ExternalID, QuestionLabel|
- The BaseURL includes the security token and panel id required by the API service, for example:
- The ExternalID is the name of the hidden Q_Survey question which contains the external panellist ID required for the API call, in our example this is called ExternalPanellistID.
- The QuestionLabel is the name of the variable in Q_Panel (this is not necessarily the same as the name of the question in Q_Survey).
- The Rows parameter is the number of rows in the grid question (and therefore the number of variables stored in Q_Panel).
For example, the Reference field could contain the following to retrieve the current value of the Gender variable:
Setting the current value on the questionnaire
For each survey question another function call needs to be added which sets the value retrieved. The function call required depends on the type of question:
If the question is an interactive question, click on the Edit definition (advanced) button (bottom left):
At the bottom of the script, change the iQuestFire function to include a call to the appropriate function for the question type:
For non-interactive questions click on +Add and select Html Code, PageReady() Template and insert a call to the appropriate function for the question type: