Hi,
We have a CSV file that stores product attributes, e.g., colors. In our survey, we would like the user to be able to update the colors for that product. When a user selects a product from a drop-down list, we want a read-only question that queries the CSV file and returns a list of the current colors for that product. This question would serve two purposes: 1) allow us to store the information in our database to see what the colors were before the user made any changes; 2) be FYI for the user so they can see the current colors.
Then, the second question would be a select_multiple question displaying a list of all available colors with the currently assigned colors pre-selected. The user would then be able to select/de-select the colors as necessary to update.
My questions are:
Thank you!
Solved! Go to Solution.
In Survey123, you can't use Javascript with local files - so no working with CSV files. To do what you want, you'd need to load the CSV to your server and convert it to a JSON and then work with the JSON.
But I don't think JS is the optimal solution for what you want to do. If I understand you correctly, this can all be accomplished quite easily using the 'pulldata' and 'select_one_from_file' functions and setting the default of the second question to the response for the first.
I'm not sure what you mean when you say that returned values are not stored when the user submits the survey. So long as the type isn't bound to null, it should be uploaded to the database.
In Survey123, you can't use Javascript with local files - so no working with CSV files. To do what you want, you'd need to load the CSV to your server and convert it to a JSON and then work with the JSON.
But I don't think JS is the optimal solution for what you want to do. If I understand you correctly, this can all be accomplished quite easily using the 'pulldata' and 'select_one_from_file' functions and setting the default of the second question to the response for the first.
I'm not sure what you mean when you say that returned values are not stored when the user submits the survey. So long as the type isn't bound to null, it should be uploaded to the database.
I was overthinking things. Thank you so much!! This worked.