I’m looping over a document list in a flow service (IS 6.01). When I see a particular item I need to process it (extract some values) and then remove the item from the list. I tried adding a map step in the sequence that handles this item, which simply drops the item, but that didn’t result in the item being removed from the output. Any ideas how I can do this? TIA.
Here is a suggestion/idea, just off the top of my head as I read your post. I am sure there are probably better ways to do this.
Instead of removing the extracted data from your original document list(which I am guessing is the hard part), why don’t you build two document lists, one for the data that you want to extract and one for the original record list. If you find something to extract, write it to extract document list and if you don’t, append to a temp document list that will represent the original, minus the data you want to extract. Then drop the original list and map the temp document list to the original list.
I think that this is easily accomplished in a branch and several map steps.
Hope this helps.
Thanks Andrew. I thought of doing something like that as a work-around, but it would seem to result in some unnecessary processing that I’m hoping to avoid. After some further testing I’ve noticed that the in-array in a loop is apparently restored (in its original condition) when the loop exits. This seems to be what’s overriding my removal of the item in the loop. Does anyone know if this is expected behavior, or if there’s any way around it?
String lists and record lists are implemented as Java arrays. There is no exposed service to remove an item from the array and then collapse the array down.
Dropping the array element within the loop has no effect on the array itself. Looping “overloads” the use of the array name and uses it as the element name while inside the loop. Thus, if you have a list named “foo” and loop over it, the array element reference is also named “foo”. Dropping “foo” only drops the loop’s reference to the element and does not touch the array itself. (Hope this is presented coherently.)
Here is another case where it might help to think of the loop in terms of Java: if you had an array of objects that you looped over, you probably wouldn’t even think of trying to remove them from the array. You’d probably create another array either of the processed items or the non-processed items. That’s probably the approach you need to take in this instance.
I see. That certainly confirms what observed in debug. So I’ll take the extra steps to map it out. Thanks. As always, you guys rule.