Javascript Skipped | XM Community
Skip to main content

Good morning,

in the survey I have configured there are two date values linked together. One of them in fact is calculated by javascript based on the other date (it goes back a few days).
The mechanism is active on several surveys and works fine, the reported problem is that in 2 responses out of hundreds of thousands, the javascript was not read. How is this possible? Could it be that the respondent's browser is unable to read the inserted javascript?

Best,

 

Carlo

Hi,

Can you share your script and the date/time when the errors occured?


Yes, the script is this one

 

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
   var data_ini = Qualtrics.SurveyEngine.getEmbeddedData("DT_ESTRAZIONE_21");
    //var data_ini = "10/12/2023"
    var data_ini1 = data_ini; 
    const myArray = data_ini.split("/");
    var data_ini = myArray 1]+"/"+myArrayr0]+"/"+myArrayr2];
  console.log("Data iniziale: "+data_ini); //04/07/2023 4 luglio 2023 martedì

function getPreviousDay(date = new Date()) {
  const previous = new Date(date.getTime());
  previous.setDate(date.getDate() - 1);

  return previous;
}

const d = getPreviousDay(new Date(data_ini));
d.setHours(10, 0, 0, 0);
console.log(d);
Qualtrics.SurveyEngine.setEmbeddedData("DT_ESTRAZIONE_21",data_ini1);
Qualtrics.SurveyEngine.setEmbeddedData("DT_COMPETENZA",d);
});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    /*Place your JavaScript here to run when the page is unloaded*/

});

and the skipped date (DT_COMPETENZA) is this:

 


Best,

Carlo​​​​​​​


Leave a Reply