This script allows you to ask participants for their zip or postal code in a Zip / Postal Code question, and then write the answer values back to an Open End zip or postal code profile variable. Doing so lets you leverage the validation that is already available in Zip / Postal Code questions.
Tip: This script can be used on any combination of Open End question types and Open End profile variable types.
Open End question type | Open End profile variable type |
|
|
Detailed Steps
- In your survey, add a Page element.
- Add a Zip / Postal Code question to the Page element.
- Set the Region.
- Under the Zip / Postal question, add a Profile action.
- Choose the Open End profile variable (for example, a Text profile variable that captures Postal Code).
- Select Hide question.
- Open the first Page element for editing and click the Scripting button.
- Copy and paste the script below into the On Complete tab.
- Replace VQ_Name with the name of the Zip / Postal Code question.
- Replace PV_Name with the name of the Profile action.
- Click Save.
- Preview and test your survey.
Script
/*
Script Name: How do I add values captured from a Zip / Postal Code question to an Open End profile variable? (Modern Surveys)
To ensure your script works as expected, always copy the original script
from the Script Library found in the Alida Help Center. Failure to use the latest script
from the script library may cause unexpected results.
*/
const qNotPV = response.getDataPoint("VQ_NAME");
const notPV = qNotPV.get();
const qPV = response.getDataPoint("PV_NAME");
qPV.set(notPV);
Example
Sample survey structure with Zip / Postal Code question and Postal Code Profile action on the same page:
Responding view showing just the Zip / Postal Code question:
Comments
0 comments
Article is closed for comments.