Hi - I am trying to get some help with a script I am trying to do in the postprocessor. I am trying to create a csv out put from my xml datafile. The first loop I am using works fine. My issue is in creating my second loop because I have a detail table I am trying to get at and I am not having any luck. Can anyone help me with the second loop? No matter what I try - I always end up with an undefined of something type error. I was using ‘twoRec’ for my second loop attempt. This is my last resort for help as I have had someone alot more experienced in javascript than I am trying to help me but he can’t figure it out either. I did ask this question back on July 24 and the response I received did not work so after working for three weeks on this below is where I am at. Any help would be greatly appreciated. - Thank you in advance
var fileOut = openTextWriter(“c:\out\BankSummaryFee.csv”); var str=, oneRec, twoRec, prop; // Add Column names as first line in CSV
oneRec = data.records[0];
twoRec = data.records.tables[APVendor]; for (prop in oneRec.fields){
str.push(‘"’+prop+‘"’); for (prop in twoRec.fields)
str.push(‘"’+prop+‘"’);
}
fileOut.write(str.join(“,”));
fileOut.newLine(); str = ; // Add all values for all records for (var i=0; i < data.records.length;i++){ for (var s=0; s < data.records.tables[APVendor].length;i++){ for (prop in oneRec.fields) {
str.push(‘"’+oneRec.fields[prop]+‘"’); for (prop in twoRec.fields) {
str.push(‘"’+twoRec.fields[prop]+‘"’);
}}
fileOut.write(str.join(“,”));
fileOut.newLine();
str = ;
}
//Close file
fileOut.close();
Hi Phil - thank you. I have tried the code above and while I do not get any errors, the only data it is producing is from the first loop. For example - my data structure looks like this.
record [1]
ExtraData
RunDate 06/21/2017
Payable 06/30/2017
I corrected my post just seconds after posting it, I had left my own table name in there. Did you try the version that is currently posted because it works fine on my end.
All right, all seems in sync now. Glad I could help.