I'm being asked to integrate JavaScript into Qualtrics to accomplish the following three steps:
Note: This isn't in my wheelhouse and I'm having quite a bit of trouble accomplishing this task.
Here's a snippet of code that I've generated thus far:
//add 3 months from current date;
var someDateM3 = new Date();
var numberOfDaysToAdd = 90;
someDateM3.setDate(someDateM3.getDate() + numberOfDaysToAdd);
var month3 = someDateM3.toISOString();
//assign value of month3 to embedded data field 'month3';
Qualtrics.SurveyEngine.addEmbeddedData( 'month3', "${e://Field/month3}");
Am I on the right track? I lack the training and skillset required to complete this seemingly straightforward task. Any advice would be incredibly helpful.
I think your date calculation is fine. The problem is with saving it to an embedded data variable. That should be:
Qualtrics.SurveyEngine.setEmbeddedData('month3', month3);
You need to define the embedded data variable month3 in the survey flow prior to the block that contains the question with your date calculation JavaScript.