How to read/fetch data from an (external) source (e.g. csv file or Database) to my customized question? | XM Community
Skip to main content

Hello Everyone,

 

I am trying to pull/fetch data (Full Name & Email) of my survey's applicants in a custom-made question(attached PNG file), which I have developed using html, css, and javascript on the Qualtrics platform.

In this question, I let the users type some characters of either their full name or their email and I autofill/autocomplete for them the rest information of the field that they edit as well as the corresponding value of the other field. For the moment, I have initialized a variable called 'data', where I provide-hardcode the parameters/values for these two fields (Full name and Email) and based on these values I do the auto-completion for the users (For more information check the code in the attached file).

Ideally, I am looking for a solution/suggestion from you, on how I can pull/fetch the needed information(Full name and email of the users) from an (external) source ( e.g. Excel-CSV file, Qualtrics contact list, embedded data field, etc.) to my custom "Autocompletion" question. 

 

Thank you very much in advance.

Moved this one to the Custom Code category -- curious to see what our Custom Code experts have to say on this one! 🤓


You could use https://projects.verou.me/awesomplete/#advanced-examples see the Ajax example.


Dear @ahmedA,

Thank you very much for your response. However, when I integrate the provided code from the “Ajax” example it seems that it is not possible to fetch the data from the external source, I think mainly for two reasons:

  • The recommended code seems to work fine mostly with APIs.
  • The organization's restrictions to link sharing, prevent the algorithm from accessing the data with the GET method. That's why I am inclined to believe that a solution utilizing the Qualtrics library or a DB system is more likely to work for my case.

Dear @Michael_Cooksey,

 

Thank you very much for this.


@TelisKan

To access external data with ajax from any site other than Qualtrics, the server side script must include an appropriate Access-Control-Allow-Origin header in the output. This applies regardless of the data source (database, etc.). If you don’t control the web service, you can’t add the Access-Control-Allow-Origin header.

If you have access to a web server you can create a database table there and write a web service to retrieve the data from the database. Then use ajax to call the web service from your question.  

Otherwise, you are limited to storing the data on Qualtrics. There are two possible options:

  1. Use the Qualtrics Autocomplete Questions functionality if it is available on your account (it probably isn’t)
  2. Upload the csv to your Qualtrics library and use JS to retrieve the data with ajax and parse it.

 


Dear @TomG ,

 

Thank you very much for your response.

I have contacted my organization's brand administrator, and the Autocomplete Questions cannot be enabled for my account.

So I worked more intensively on your second suggestion (also what I had in mind) and tried to fetch the data from a CSV file in my Qualtrics library. In the attached text file you can find the full JS code that I have developed to achieve such a functionality.

 

Here are the specific steps that I followed:

1)Put the following libraries in: Look and Feel → General → Header (in the source)

<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

2)Insert my HTML/CSS code to structure the question layout/look in a Text/Graphic question's HTML VIEW

3)Put the JS code from the attached txt file in the JavaScript of my question from the Question behavior.

 

 

 

 


Leave a Reply