We are using WmEDI package to parse CSV files, convertToValues returns a recordList for the CSV records - this works fine when we have 2 or more records in the CSV file.
The problem occurs when we have one record in the CSV file, convertToValues returns a record instead of recordList with one record hence the LOOP fails -
I encountered a similar problem in wm visually shows a recordList in the pipe but internally treats it as a record if there is only one record in the list. Therefore methods such as loop fails because there is no list to loop through.
The way I worked around it was to use a Java service to test if the record was in fact a list. If the service returned true the you can loop and use all the methods that work on lists. If the service returned false I treated is as just a record and not a list.
I don’t know if this a bug or it’s the way wm is intended to work. Seems like a bug to me.
Anyway here’s the Java code for the service.
input object obj
output string isList
I’ve seen this problem before and you’ll experience the same problem when
using templates as well. I wrote my own java service to read a csv file
into a record list. I just pass in an initialised record and the full csv
file path. There’s a free CSVReader class out there you can use to develop
this service. Just use google to search for this class. Also this class can
handle embedded spaces and commas.
I have been seeing this posting go back and force I think I have a simple solution for you. WM has this well known problem turning any single element into a records instead of list. I created a service that ensures that no mater what record object passed the output will be a list or array even with single element so you Loop will work anyway. Here is a source: