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

Fulfill a field using javascript


Forum|alt.badge.img

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?

Best answer by bstrahin

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/

View original

7 replies

bstrahin
Level 6 ●●●●●●
Forum|alt.badge.img+38
  • Level 6 ●●●●●●
  • 638 replies
  • May 4, 2022

Forum|alt.badge.img

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.


bstrahin
Level 6 ●●●●●●
Forum|alt.badge.img+38
  • Level 6 ●●●●●●
  • 638 replies
  • Answer
  • May 4, 2022

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/


Forum|alt.badge.img

Thanks, Madison, that helps a lot.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5923 replies
  • May 5, 2022

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


Forum|alt.badge.img

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


Forum|alt.badge.img

Thanks Betsy and Thomas. Now I know your names 😊


Leave a Reply