Embedded Field not populating in Data & Analysis tab before page submits? | XM Community
Skip to main content
Question

Embedded Field not populating in Data & Analysis tab before page submits?

  • July 29, 2020
  • 1 reply
  • 15 views

Hi Team,
Embedded Field not filled before page submits as I guess..

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
var apiResponse = JSON.parse(this.responseText);
var contactInfo = apiResponse.result.elements[0];
firstName = contactInfo.firstName;
lastName = contactInfo.lastName;
Qualtrics.SurveyEngine.setEmbeddedData("ContactFirstName", firstName);
Qualtrics.SurveyEngine.setEmbeddedData("ContactLastName", lastName);
alert(Qualtrics.SurveyEngine.getEmbeddedData("ContactFirstName"));
// Here I am able to get the first name in alert But this field not updating first name in Data & Analysis tab of Survey
}
Api is returning correct response in var apiResponse

1 reply

Rusty
Level 1 ●
Forum|alt.badge.img+2
  • Level 1 ●
  • August 3, 2020

How about trying setting the embedded data on a click versus page submit. see code below. Also, make sure your set embedded data block is before the survey question block in survey flow.

jQuery("#NextButton").on('click',function(){