Dynamic loop and merge block using panel data json file | XM Community
Question

Dynamic loop and merge block using panel data json file

  • 15 October 2020
  • 1 reply
  • 38 views

Hi,

I have a requirement, where a survey is sent out to employees, and the employee will answer the same set of questions regarding each of their employees. The employers have a different number of employees, but the same questions will be asked about each employee.

  1. Staff member 1

Is this staff member a good employee? Y/N
Does this staff member require training?
Who is the staff member's supervisor?
  1. Staff member 2

etc based on a dynamic json file.

My question is, how do I parse this dynamics JSON file, which will be uploaded to the panel data as a field. into the Loop and merge data?
a sample JSON file is here,
{"items": [{"index": 1,
"name": "Nina",
"surname": "Underwood",
"email": "lillian@raynor.nf",
"bool": false
},
{"index": 2,
"name": "Chris",
"surname": "Baker",
"email": "jimmy@hirsch.mt",
"bool": true
},
{"index": 3,
"name": "Melinda",
"surname": "Sanchez",
"email": "brent@greenberg.sx",
"bool": true
}
]
}


1 reply

Userlevel 7
Badge +27

You would probably be better off using a web service to get the json directly from the source and it will populate embedded data fields for you that you can pipe into the loop & merge. It would also save you from having to keep a contact list up to date with the json data.
To use the json data from the contact list, you can pipe the embedded data field into JavaScript, parse it with jQuery.parseJSON(), then save it to separate embedded data fields. You can then pipe those fields into your loop & merge.

Leave a Reply