How do I cycle through Blocks selectively (Loop & Merge-style) based on age values in embedded data | XM Community
Skip to main content

I'm creating a survey where the respondent answers the same set of questions about each of their children (up to 5 of them). The names and ages of each of their children are embedded data in the contact list, i.e., for each respondent in the panel, there are potentially values for:

num_kids (the maximum is 5)
child_name_1
child_age_1
child_name_2
child_age_2
...
child_name_5
child_age_5

If the person has fewer than 5 children, then not all the variables above will have values. But each person has at least 1 child.

Here's the challenge:
The survey questions are divided into 10 blocks of questions. Seven of the blocks, we want to administer in regard to every child the person has. I thought of using Loop & Merge but am not sure how to base Loop & Merge on embedded (piped) data.
But the bigger challenge is this: For the remaining 3 blocks of questions, we only want to administer them in regard to each child that's at least 3 years old. Loop & Merge? Display Logic? I'm having a hard time figuring out how to do this without using JS. If there's no other way, I'm definitely willing to use JS but would need help with the code. (I have quite a bit of JS experience but am not a master JS programmer.) And I'm not sure if some people shut off JS in their browsers -- if they do, the survey wouldn't work.
Any advice would be most appreciated!
Thanks!

Step 1:
image.pngimage.pngimage.pngimage.pngimage.png
Step 2: Custom validation for 2nd question"
image.pngOutput:
image.png
image.png


Leave a Reply