How to get value of looped field one loop before the up-to-date one? | XM Community
Skip to main content
Solved

How to get value of looped field one loop before the up-to-date one?

  • November 9, 2021
  • 2 replies
  • 31 views

In a question inside a looped block, I have to print the up-to-date value of a looped field, i.e.

${lm://Field/1}
and the value of the same field one iteration before. How can I access that previous value?

Best answer by MSobotta

Are trying to display just a previous field and not the answer? Are using a randomized order in loop and merge? Are you using all of loops?
If you answered Yes, No, and No to those questions, you can then just add an additional field which holds the previous loop's value(s). Follow? If you answer anything else I don't know how you would do it without js.

  1. Field Value 1, empty

  2. Field Value 2, Field Value 1

  3. Field Value 3, Field Value 2

  4. Field Value 4, Field Value 3

So when you are calling in the questions: ${lm://Field/1} ${lm://Field/2}.

2 replies

MSobotta
Level 4 ●●●●
Forum|alt.badge.img+25
  • Level 4 ●●●●
  • Answer
  • November 9, 2021

Are trying to display just a previous field and not the answer? Are using a randomized order in loop and merge? Are you using all of loops?
If you answered Yes, No, and No to those questions, you can then just add an additional field which holds the previous loop's value(s). Follow? If you answer anything else I don't know how you would do it without js.

  1. Field Value 1, empty

  2. Field Value 2, Field Value 1

  3. Field Value 3, Field Value 2

  4. Field Value 4, Field Value 3

So when you are calling in the questions: ${lm://Field/1} ${lm://Field/2}.


  • Author
  • November 9, 2021

MSobotta thanks, yes, that's what I want to achieve and I got your approach by populating a new field with an offset. It's pragmatic and working! If anyone has a solution with javascript, I'm interested also.