How to record the current date to the embedded data? | XM Community
Skip to main content

Hi all,

 

First of all, I appreciate all posted answers and discussions in this community. They are helpful and have answered most of my questions. 

 

I am trapped in a JavaScript coding issue. My goal is to record the dates on which respondents answered specific questions in my survey via an anonymous link. I've set up the embedded data in the survey flow and then entered the code I learned from this community. However, the date cannot be recorded. Below is my code:

Qualtrics.SurveyEngine.addOnReady(function()

{

               /*Place your JavaScript here to run when the page is fully displayed*/

               var curDate = "${date://CurrentDate/m%2Fd%2FY}";

               Qualtrics.SurveyEngine.setEmbeddedData( 'DateConsentFormSub', curDate);

 

});

 

I am grateful for your consideration of this question. Thank you!

@Lizy First, you have to set an empty embedded data field named “DateConsentFormSub” at the beginning of your surveyflow. That let the system know that it should saving this field value in the record. 

Hope this helps


Hi @dxconnamnguyen, Thank you so much for your suggestion! I tried that, though, it didn't work. I also tried to change the variable defined as “__js_DateConsentFormSub” and then used the setJSEmbeddedData. However, either this method or the method you suggested didn’t work.Is there any other method to try? Thanks again for your help!


Hi @dxconnamnguyen, I changed the code location within the Qualtrics.SurveyEngine.addOnload(function(){}). And now, it works!!! Thanks again for your help! I do appreciate it!


Leave a Reply