Question
Javascript code randomly failing
In our surveys we need, for each respondent, the date in which the survey was sent to them (not the date in which they started it). For this, I have an API call in the survey flow which brings me the transaction date. Up to that point it works fine. The problem is that the transaction date comes in the format "2020-02-27 21:46:20" and I need it in "27/02/2020", so I added a javascript code to our first question that does the following:
var str = "${e://Field/transactionDate}";
var parts = str.split(' ');
parts = parts[0].split('-');
year = parts[0]
month = parts[1]
day = parts[2]
let newDate = day + '/' + month + '/' + year;
Qualtrics.SurveyEngine.setEmbeddedData("DATE", newDate);
This works fine 99% of the time, but it sometimes fails to execute and DATE ends up empty. I added UserAgent to the survey flow to see if this happens with older mobile devices but it also happens with newer ones. Does anybody know why this could be happening, and how to solve it? Thanks!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
