jjdodger Posted September 29, 2017 Posted September 29, 2017 This is a theory question, more than a "need it now" question: Can FP create an array of objects from an external data file, on record start, that can then get parsed/walked through/etc, by another function or functions? As an example, I had to do a project once, where 1 record could have 1 to 200 detail lines, and needed to build a table based on the number of detail lines. The final document was 8 pages long, with the middle 4 being the table, and if a page was blank, print "intentionally left blank" across the middle of the page. It also needed a series of totals printed as the last line of the table, calculated from the data. Is this do-able? The only real example i would need to recreate this would be how to create the object, and how to iterate through it from another rule. I hope this makes sense! Thanks Jeff Quote
step Posted September 29, 2017 Posted September 29, 2017 Sure, it's possible; check out the static example below. Just create the array as a JavaScript Global: globalArray = []; Then you can populate the array at the start of each record in OnRecordStart: for (var i = 1; i <=5; i++) globalArray.push({ 'recordNumber': i, 'fieldData': 'Value' + i }); Then your rule could walk the array: var result = ''; globalArray.forEach(function(s) { result += 'recordNumber: ' + s.recordNumber + '. fieldData: ' + s.fieldData + '.<br/>\n'; }); return result; Then your rule would return: recordNumber: 1. fieldData: Value1. recordNumber: 2. fieldData: Value2. recordNumber: 3. fieldData: Value3. recordNumber: 4. fieldData: Value4. recordNumber: 5. fieldData: Value5. Quote
jjdodger Posted September 29, 2017 Author Posted September 29, 2017 Just to clarify a few minor things: I do not need to declare a layout or format for the array? will it rebuild the array on each "on record start" call? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.