It is a great help. It would be days before I got this far. I can't thank you enough.
Hardcoding the path, in OnJobStart, doing a return sorted_data; result in this
[object Object],[object Object],.............
but in OnRecordStart return recFlag; results in the value of "Order Number" being displayed in ascending order.
The output pdf is not affected, though a pdf named undefined.pdf is output additionally. They are identical in content, number of pages, etc. The data has 5 different "Order Numbers". I imagine I have something wrong in OnRecordStart. example_template.zip