Using Variables in Javascript Piped Text | XM Community
Skip to main content
Solved

Using Variables in Javascript Piped Text

  • January 15, 2021
  • 2 replies
  • 238 views

Forum|alt.badge.img

Hi everyone,
I am trying to record the values of multiple questions using piped text, based on a variable. A simple example that doesn't work correctly for me:

id = 'QID191'

i1 = '${q://'+id+'/SelectedAnswerRecode/1}'

whereas this code functions just fine:
i1 = '${q://QID191/SelectedAnswerRecode/1}'

I assume this has something to do with how the strings/piped text get parsed in Javascript, but I've tried searching around for some solutions without too much success. Thanks!

Best answer by TomG

https://www.qualtrics.com/community/discussion/14096/using-variables-in-javascript-piped-textPiped fields are resolved on the server before they are sent to the browser. So, you can't dynamically create piped fields in JS.

2 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • January 16, 2021

This is most likely due to how template literals are evaluated in Javascript.
Perhaps you could try around with

eval()
.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • January 16, 2021

https://www.qualtrics.com/community/discussion/14096/using-variables-in-javascript-piped-textPiped fields are resolved on the server before they are sent to the browser. So, you can't dynamically create piped fields in JS.