Groovy script to aggregate data in each iteration from POST request
- 3 years ago
If the datasink is inside the loop, then it should record each response. Without a screenshot, it's really difficult to properly help. You may have simply configured it wrong.
As for properties, the value will be overwritten on each iteration. Now, the properties are string name/value pairs. I'm assuming that you don't know how many iterations, so you could concatenate each value to the string and aggregate after the loop.
E.g.
Initial ""
Loop 1 : "20,"
Loop 2 : "20,23"
Loop 3 : "20,23,26"
etc.
Or have have two property values and total up on each iteration. E.g.
Initial : running-total = 0. count = 0.
Loop 1 : running-total = 20. count = 1.
Loop 2 : running-total = 43. count = 2.
Loop 2 : running-total = 69. count = 3.
Be aware, property values are strings. Before calculating them, you'll need to convert to integer and convert back to sting when saving them.