Question T10146
Visible to All Users

Is It Possible to Loop Through Data Retrieved From API?

created 2 years ago (modified 2 years ago)

Hi!

We have a requirement to display a survey to a user, and at a certain point during it, loop through the same series of questions for each medical certificate the person has earned.

For example:
Question 1: Name
Question 2: Something else

…then…

For each medical certificate the person has earned
Question 3
Question 4
Quetions 5

Is it possible to retrieve the data from the API and pass it to the survey when the model is created? Also, the questions would need to display the name of the medical certificate. I was thinking that data variables could be used here, but the documentation states:

"variables can be used in expressions and text processing, cannot be used in questions, and are not stored in survey results."

Thanks!
Alan

Answers approved by surveyjs Support

created 2 years ago

Hello,

If you are asking about results stored on our site https://surbeyjs.io then there are the following Web API endpoints to access survey results:
https://surveyjs.io/Help/Api/GET-api-Survey-getResult_resultId_name?apiType=public&renderType=desktop
https://surveyjs.io/Help/Api/GET-api-Surveys-getSurveyResults-id_accessKey_from_till?apiType=private&renderType=desktop
You can get the certain survey result and assign in to survey. This case is illustrated with this example - https://surveyjs.io/Examples/Library?id=survey-data&platform=jQuery&theme=defaultV2

Our site doesn't have an API to work with result inner content. It allows to get the whole result JSON.

Note that our survey service is just a large demo illustrating what you can achieve with our products. We don't guarantee 24/7 uptime, data safety and security for data stored on our site.

Thanks, Serge
SurveyJS Team

    Comments (3)

      Hi Serge!

      No, that's not the API I was referring to. The API I'm referring to is one of our own. We have an API that returns a list of medical certificates earned by any given doctor. We need our survey to be able to ask them a few questions up front, and then loop through the same 5 questions or so for each certificate earned. Is this something we can do with SurveyJS, and if so, how?

      Thanks!
      Alan

        Hello,

        Do you want to loop a part of a survey? Unfortunately SurveyJS doesn't support loops.
        You can:

        Thanks, Serge
        SurveyJS Team

          Thank you Serge for the information!