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:
- On the Web/CATI tab, select the JavaScript file field and enter the following file (you may be able to select it from the Scripts folder if it is available):
//rs.miprocloud.net/PortalDataService/Content/9fn3Bwbj8QX/panelConnect.js
(This script contains the 'Set' functions).
- On the Advanced tab select the Script file field and enter the following file:
~\Scripts\PanelConnect_704.vbs
(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:
Question Type | Function | Parameters |
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 |
Where:
- 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:
\script:fncGetSingleExternal('http://test-api.quenchtec.net:50070/v1/123b4ab5-c6d7-89e1-23f4-ab567890f1c2/a123456c-de7f-89ab-0123-5cde6c7fa89b/',\ExternalPanellistID,'Gender')
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:
Question Type | Function |
Single | fncSetPanelSingle |
Multiple | fncSetPanelMultiple |
Single Grid | fncSetPanelGridSingle |
Multiple Grid | fncSetPanelGridMultiple |
Numeric | fncSetPanelNumeric |
Open | fncSetPanelOpen |
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: