Reputation: 834
Following is my test plan. Where ForEach controller should loop through all the task Ids stored in user defined variable "userTaskIds". I tried defining list with
both def myList = [] and List<Object> listId = new ArrayList<Object>();
. In both the case its failed to loop.
ForEach controller not looping with "userTaskIds" variable. Here i tried with/without "add "_" before number ?"
Following are debug sampler result and Log view panel
Log View
Upvotes: 2
Views: 8117
Reputation: 34536
This is because ForEach Controller expects this:
And
So in your JSR223 script you need to do this in each loop iteration :
Replace responseJSON.each by
responseJSON.eachWithIndex {
it, iterationLoop ->
Then
vars.put("userTaskIds_"+(iterationLoop+1), ""+it.id)
where iterationLoop must start with 1 and be incremented.
and after loop:
vars.put("userTaskIds_matchNr", Integer.toString(myList.size()));
Upvotes: 3