Loop and merge based on embedded data field from web service | XM Community
Solved

Loop and merge based on embedded data field from web service

  • 27 January 2024
  • 2 replies
  • 66 views

Badge +1

Hello, 

 

I am providing some sample products for my customers to taste.
 

The customers and each will select up to 5 and will get the survey to rate them.

I retrieve those products through a webservice which then feeds the embedded data (product name).

 I set the embedded data in the begining of the survey flow  with product names as Product_Name1, Product_Name2 etc.

Then I map those embedded data from the webservice as below: (url is empty for now, I will do the testing later) 

 

The questions will be the same for each product so I will use Loop&Merge functionality.

 

However, when I set the loop&merge based on the embedded data and as the customer might choose less than 5 products, I don’t know how to stop loop&merge if the embedded data turns empty. For example, if the customer chooses 3 products, Product_Name4 and Product_Name5 will be empty and I want to stop the loop after the 3rd time. 

 

Is there any way to set a condition in the survey flow to stop when the embedded data is empty by using the loop&merge functionality ? Or is there any custom code to make it happen?

Thanks in advance.

icon

Best answer by TomG 27 January 2024, 22:44

View original

2 replies

Userlevel 7
Badge +27

@sdevrez,

Add a MC question before the loop and add a choice for each product. Add display logic to each choice to only display it if the associated product name is not empty. Hide the question with JS and base the loop off the displayed choices in the question.

Badge +1

Brilliant @TomG thank you very much. It worked perfectly :)

Leave a Reply