Using embedded data in piped text code | XM Community
Skip to main content
Solved

Using embedded data in piped text code

  • October 27, 2018
  • 4 replies
  • 63 views

Forum|alt.badge.img
Is it possible to use embedded data in piped text code? Specifically, I’m trying to choose which loop and merge column (not row) is used based on which response is picked in an earlier dropdown list. So, I’m trying to save the order number of their selection from the dropdown list (embedded data in Survey flow: selection = $e{ q://QID1/SelectedChoicesRecode + 1 }) and pipe that number into the loop and merge piped text code so that it selects the correct row when populating that part of my question (e.g., How often do you shop at ${lm://Field/selection}?). Is there a way to make this work?

Best answer by TomG

> @teammiele said: > @TomG : So even if an embedded data variable (or maybe a variable in javascript) contains a number (specifically the number of the field that I would like my loop and merge code to call), there's no way to use that number in my loop and merge code to call that field? Correct, you can't dynamically build a piped string with a JavaScript variable or a pipe within a pipe. The reason is that pipes are resolved on the survey before the page is sent to the browser, so you can't modify them in the browser. For more details see this thread: https://www.qualtrics.com/community/discussion/2481/how-to-create-piped-text-in-javascript-and-use-its-value

4 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • October 27, 2018
No, you can't. Loop and merge can only be field numbers. You can pipe values into your loop & merge set up. So, for example, you can pipe `$e{ q://QID1/SelectedChoicesRecode + 1 }` into Field 1.

Forum|alt.badge.img
  • Author
  • October 27, 2018
@TomG : So even if an embedded data variable (or maybe a variable in javascript) contains a number (specifically the number of the field that I would like my loop and merge code to call), there's no way to use that number in my loop and merge code to call that field? To clarify, if they choose the first item in the dropdown list, I don't want my loop and merge Field 1 to contain the number "1", but rather I want to call Field 1; if they choose the second item in the dropdown list, I don't want my loop and merge Field 1 to contain the number "2", but rather I want to call Field 2; etc. Does that make sense?

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • October 27, 2018
> @teammiele said: > @TomG : So even if an embedded data variable (or maybe a variable in javascript) contains a number (specifically the number of the field that I would like my loop and merge code to call), there's no way to use that number in my loop and merge code to call that field? Correct, you can't dynamically build a piped string with a JavaScript variable or a pipe within a pipe. The reason is that pipes are resolved on the survey before the page is sent to the browser, so you can't modify them in the browser. For more details see this thread: https://www.qualtrics.com/community/discussion/2481/how-to-create-piped-text-in-javascript-and-use-its-value

YASH1T
QPN Level 2 ●●
Forum|alt.badge.img+6
  • QPN Level 2 ●●
  • October 29, 2018
@teammiele As mentioned by @TomG piped text cant be build dynamic, you can try using JS as follow: add a place holder in place of piping in questin text (e.g. <span class="ph">   </span>)and update this placeholder through javascript (as you know which filed to pipe in from selection embedded variable, so just replace content of .ph with that field )