Hello All. I am trying to use luxon to change the format of a date provided (from DD/MM/YYYY to ISO 8601) in measure one of a longitduinal study in preparation for automating an email distribution of a second survey link on the date provided by respondents in the first measure. I have used various responses to similar topics on the forum to get this far, mainly this thread although have changed from moment.js to luxon as I understand this is a newer equivalent option.
However, the adjusted date is not populating in my survey data after a preview. The user inputted date comes through fine. And therefore I am unable to pipe the embedded adjusted date to automate my email distribution for the correct date for each individual participant.
The steps I have taken as as follows:
Added this code to the header. I am not in simple layout, I am in flat.
<script src="https://cdn.jsdelivr.net/npm/luxon@3.4/build/global/luxon.min.js"></script>
Added this code to the question collecting the date in the first measure.
Qualtrics.SurveyEngine.addOnload(function() {
const { DateTime } = luxon;
var userDate = "${q://QID15/ChoiceTextEntryValue}";
if (userDate) {
var parsedDate = DateTime.fromFormat(userDate, "dd/mm/yyyy");
if (parsedDate.isValid) {
var adjustedDate = parsedDate.toISO();
Qualtrics.SurveyEngine.setEmbeddedData("AdjustedDate", adjustedDate);
}
}
});
The question is a text entry question with a forced reponse and custom validation for DD/MM/YYYY, achieved by setting “Matches Regex” to ^(01-9]|^12]10-9]|3201])\/(0[1-9]|1(0-2])\/10-9]{4}$ . I have checked that QID15 is the correct QID (by looking in the downloaded csv of the data after previews).
I have placed the embedded data, with the variable set to text, for after the block with the relevant question in (Block DateQ in the below screenshot). I have also isolated that question into it’s own block after I read this helping someone else, but this is not neccesary for my design, and it hasn’t made a difference to my issue. Originally the question was in the middle of a block. I have tried placing the embedded data immediately before the question too, and also both immediately before and immediately after the question simultaneously, and nothing has worked.
Any help in identifying where my issue lies would be much appreciated. Thank you.