Question T8182
Visible to All Users

Using external data in a survey

created 3 years ago

Hi
We have a survey where we want to calculate age at an event using date of birth.
We already know the user's DOB before we start the survey, saved in our database.
Can we pass the DOB into the survey as a parameter, to avoid asking it again?
Or is there another way to pull it from the database with a custom function?

Answers approved by surveyjs Support

created 3 years ago

Hello Archie,
Sure, you can use a variable. Here is the example to set the variable: survey.setVariable("age", yourAgeValue). After that you can use this "age" variable in expressions like a question value, for example, visibleIf: "{age} > 23".
Please note, variables are not store in survey.data.

Thank you,
Andrew
SurveyJS Team

    Comments (2)

      Thanks Andrew, but I don;t understand how I am going to set the different values of "yourAgeValue" for each user?

        It is a different session on your server for your users and you can render a different code for Survey Library.
        There are many ways to implement this and it is mostly depends on your server platform and your needs.

        Thank you,
        Andrew
        SurveyJS Team