Using embedded data in piped text code | XM Community
Skip to main content
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?
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.
@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?
> @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
@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 )

Leave a Reply