Create loop, execute, then continue with main flow

One Star

Create loop, execute, then continue with main flow

Hi
Im trying to solve something like this :
In main flow I call webservice, got list of items, then I need to call webservice for each item I've received in a loop, find correct subitem (response from webservice in loop) and continue with main flow.
So basically in pseudocode I need this :
list = webserviceCallback();
foreach(item : list) {
   response = webserviceCallback(item);
   if(item == expectedResult) {
       result = item;
       break;
   } 
}
continue main flow ...

What is the best way to achieve this ?
I tried the subjob, but Im not sure how to pass input variable there and retrieve output.
Another posibility would be create some sort of 'subflow' in main job, but Im not sure how to do this either.
Any thought or suggestions are welcome...
One Star

Re: Create loop, execute, then continue with main flow

I found a solution - 
1. create subjob
2. you can send input variables using context - subjob can has his own variables, which are not visible to context of main job
3. Output can be done via context variable by passing something by reference (e.g. concurenthashmap)