web stats
Mirth Community - View Single Post - Batch processing edi 834 files
View Single Post
  #12  
Old 05-22-2019, 05:02 AM
ashishshetty1992 ashishshetty1992 is offline
Mirth Newb
 
Join Date: Jan 2018
Location: Boston
Posts: 17
ashishshetty1992 is on a distinguished road
Default

The script in Split Batch By JavaScript should be as simple as this. Set data type to "Raw".
Code:
var line = '';
var message = '';
var array;
var header;

while (line = reader.readLine()) {
    header = line.substring(0, line.indexOf('~INS')) + '~\n';
    array = line.split('~');
    for (var i in array) {
        if (array[i].substring(0, 3) == 'INS') {
            message += '---\n' + header + array[i] + '~\n';
        } else {
            message += array[i] + '~\n';
        }
    }
}

return message;
PS: The "---\n" is only to separate each INS group. You can take that out if you wish.
Reply With Quote