Fulfill a field using javascript | XM Community
Skip to main content

Hi everybody, I tried to fulfill the field age using the code below:
Qualtrics.SurveyEngine.addOnReady(function()
{
Qualtrics.SurveyEngine.setEmbeddedData("Age", "44")
});
The field is like this:
temp.jpgBut it doesnt work. How can I do that?

See this documentation on setting a default answer. No need for javascript.

https://www.qualtrics.com/support/survey-platform/survey-module/question-options/add-default-choices/#DisplayingPipedTextInDefaultChoices


Thanks for your answer, Madison.
But I need to use Javascript because my list is very large and I will read it from a CSV file, exactly when the survey is in course.


The code you have written is pointing to an embedded data field. Those can only get set in four ways:
1) from a contact list (it sounds like you are trying to not upload your .csv as a contact list. However if you did do that then the solution I gave you will work. If you are uploading the .csv into contacts look here to make sure it is reading into your survey.)
2) info in the survey link
3) built-in Qualtrics fields
4) values set in the survey flow

But maybe you are trying to use a webservice to host your .csv so I would look at this page: https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/advanced-elements/web-service/


Thanks, Madison, that helps a lot.


MarceloRychter ,
Fill a text entry field with JS like this:
Qualtrics.SurveyEngine.addOnReady(function() {
jQuery("#"+this.questionId+" .InputText").val("44");
});


Hi Raleig, that works. I could fulfill the filed. Thanks a lot.
Cheers, Marcelo Rychter


Thanks Betsy and Thomas. Now I know your names 😊


Leave a Reply