Using Variables in Javascript Piped Text | XM Community
Solved

Using Variables in Javascript Piped Text

  • 15 January 2021
  • 2 replies
  • 136 views

Badge

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!

icon

Best answer by TomG 16 January 2021, 23:56

View original

2 replies

Userlevel 7
Badge +21

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

eval()
.

Userlevel 7
Badge +27

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.

Leave a Reply