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

Embedded data field with JavaScript is not appearing?

  • Feb 11, 2023 11:53 PM UTC
  • 10 replies
  • 330 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 ●●●●●●●●
  • Feb 12, 2023 1:47 PM UTC

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
  • Feb 12, 2023 4:05 PM UTC

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Feb 12, 2023 4:26 PM UTC

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


  • Author
  • Feb 12, 2023 4:45 PM UTC

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Feb 12, 2023 6:03 PM UTC

Please note my first comment.


  • Author
  • Feb 12, 2023 6:08 PM UTC

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 ●●●●●●●●
  • Feb 12, 2023 7:20 PM UTC

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
  • Feb 13, 2023 12:17 AM UTC

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 ●●●●●●●●
  • Feb 13, 2023 1:49 PM UTC

  • Author
  • Feb 13, 2023 4:23 PM UTC

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