Reformat Embedded Data When You Pipe Text into Question | XM Community
Skip to main content
Solved

Reformat Embedded Data When You Pipe Text into Question

  • August 9, 2023
  • 4 replies
  • 316 views

SAustin
Level 2 ●●
Forum|alt.badge.img+7

I have an embedded data field pulling timestamp from the invite file in this format (2023-06-23 23:12:00) and I want to pipe it into a question just the date: Did you use internet on MM/DD/YYYY? I think I need javascript to convert the format and/or remove the time but all the examples I’ve found are solving way more complicated versions of this question -- any suggestions here?

Best answer by TomG

Pipe the timestamp into a span:

<span class="formatDate">${e://Field/timestamp}</span>

Then use JS to modify:

Qualtrics.SurveyEngine.addOnload(function() {
var date = jQuery("#"+this.questionId+" .formatDate");
date.text(date.text().substr(0,10));
});

 

4 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • Answer
  • August 9, 2023

Pipe the timestamp into a span:

<span class="formatDate">${e://Field/timestamp}</span>

Then use JS to modify:

Qualtrics.SurveyEngine.addOnload(function() {
var date = jQuery("#"+this.questionId+" .formatDate");
date.text(date.text().substr(0,10));
});

 


SAustin
Level 2 ●●
Forum|alt.badge.img+7
  • Author
  • Level 2 ●●
  • 6 replies
  • August 9, 2023

Thanks for the speedy response! So my question looks like the below but when I do preview (with an example timestamp included in the url: &timestamp=2023-06-23%2023:12:00) but all this span language appears verbatim in the preview. Did I mistype something?

and javascript like this: 

 


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • August 9, 2023

You need to be in HTML View to enter html in the question text.  When you type html into Normal view you get &lt;span... instead of <span...


SAustin
Level 2 ●●
Forum|alt.badge.img+7
  • Author
  • Level 2 ●●
  • 6 replies
  • August 17, 2023

That works, thank you!