Embedded data field with JavaScript is not appearing? | XM Community
Skip to main content

Embedded data field with JavaScript is not appearing?

  • February 11, 2023
  • 10 replies
  • 280 views

I have an embedded data field in my question as shown below.
Screenshot 2023-02-11 at 6.45.09 PM.pngThis was the value from using the Insert Embedded Data option and writing caption1, I also tried ${e://Field/caption1} but got the same empty result.
Within the JavaScript for my question, I have the following code
Qualtrics.SurveyEngine.addOnload(function(){
Qualtrics.SurveyEngine.setEmbeddedData( 'caption1', "a" );
});
However, when I preview the page the embedded field is not shown. How can I change my JavaScript to get the embedded data to appear?
Screenshot 2023-02-11 at 6.45.33 PM.png

10 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 12, 2023

You can't pipe embedded fields on the same page you set them. The the pipes are resolved before the JS runs.
When you insert embedded data, just enter the field name, not the pipe. When you enter the pipe you get the encoded version of a pipe within a pipe: ${e://Field/${e://Field/caption1}}


  • Author
  • February 12, 2023

I see, so should I be entering caption1? That just displays the text caption1


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 12, 2023

The correct pipe is ${e://Field/caption1}, just type it directly where you want it piped.


  • Author
  • February 12, 2023

Just tried that pipe, but it's still not appearing


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 12, 2023

Please note my first comment.


  • Author
  • February 12, 2023

My apologies, if it is not possible to pipe embedded fields on the same page they are set in, what is the workaround for inserting the embedded data?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 12, 2023

https://community.qualtrics.com/XMcommunity/discussion/comment/55337#Comment_55337If you are looking to calculate or populate a dynamic value and display it, you'll need to use JS to update an HTML element.


  • Author
  • February 13, 2023

Good to know, thank you! Do you know what syntax I should be using for the HTML element (or any resources that I can use to find this out)?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 13, 2023

  • Author
  • February 13, 2023

That did exactly what I wanted, thank you so much!