I have a duplex print section. Data from my detail table needs to print on both the front and back pages. The layout is not tabular, it’s a typical form (think of a Tax Statement with the data fitting inside boxes).
All of the data is in the detail tables, the record itself just has a Javascript field that isn’t printed anywhere.
I need to output one duplex “form” per detail record. In older versions of Connect, I accomplished this with Snippets and a Control Script. The snippets had the layout and my own hand-typed “placeholders”. The Control Script looped through the detail table, and did a .replace() of the placeholder text, building an HTML response that was placed on the Print Section. This doesn’t work now that the dynamic table wizard has changed.
Is there a way to accomplish this? When I use the Dynamic Table wizard, and inside each of the generated TD elements I place a Positioned Box, and add the “data-field” parameter from the TD to the DIV (or a span inside the DIV), this simply overprints each detail field onto the same output page. The Print Section doesn’t paginate.
I thought, if I put all my fields inside of SPANs inside of DIVs, and put all the DIVs inside a single TD, and size the TD to fit one page exactly, then each subsequent TR (detail record) will naturally force pagination. That isn’t working either, same results: each detail record overprints the previous, with no pagination:
These are Tax Forms. W2s. For lottery players/winners. Each taxpayer might play the lottery once, or multiple times. The result is a CSV file that is a typical transactional file: some static data (it’s the same person, same SSN, same address, etc.) and some detail records for each bet/transaction that generated a W2.
The W2 is a two-page form. Each detail record should generate a new W2. If I played the lottery once, then I’ll have one detail record, and I’ll get a 2-page document. If I played the lottery 5 times (and won), I will have 5 detail records and should get a 10-page mailpiece (5 W2 forms).
How do I layout my template to produce one “full Print Section” per detail record?
What I’m getting is one 2-page form with each detail record overprinting the previous.
Note: this situation comes up pretty often, and was solved in previous versions of Connect. I even posted a Standard Script that worked just fine within this thread:
Another approach I see attempted and discussed is to clone a print section per detail record. There’s even a sample script for doing just that in the Help System, but it doesn’t elucidate how to increment/index the variable data for each clone to synchronize it with the detail table. All the discussions I see when I search “clone print section detail record” end up with the the data from the first detail record appearing on every clone.
I could imagine that one could edit the scripts for the detail record fields to use an index based on the clone number… but 1) detail table fields no longer produce scripts, so there’s nothing to edit and 2) I don’t think the API has any pointer to the clone "number’. Seems like a lot of functionality has been lost.
What is the proper way to loop through a detail table and produce a clone of a print section (or sections) per record? With that record’s data?
There isn’t a template to share because I cannot produce a working template! And the sample data is tax information, so I definitely cannot share that. But, ANY CSV transactional data will do, anything that has a detail table. If I have a file like:
I cobbled something together in 2022.1. For each detail record I insert a table for the front side of the sheet and a table for reverse side. I’m using CSS to automatically add page breaks after the tables so each table will start on a new page.
NOTE: I’m now on 2022.1, but my client is on 2020.2. We couldn’t upgrade them because of the HTTP Server Input authentication bug, but I moved them to NodeJS yesterday so if we end up with a working solution in 2022.1, that’s all the more reason to push them to upgrade.
Good to hear the result is what is needed. I used the Handlebars feature introduced in 2022.1. Attached my template and the sample data (I loaded the data via the JSON Sample Data option of the Data Modal view).
More information on Handlebars is found in the blog Get a grip on snippets with Handlebars. It basically describes the technique I used for this lottery sample.
The template contains a single script. It reads the detail table and loops over the record. In this process it renders the Handlebars snippet containing the front and back tables with the data of the current detail record. Personalization is handled by Handlebars and does not require additional user scripts.
The table formatting is handled via the lottery.css CSS file. I prob went a bit overboard on this as it is compiled from a SASS file. When you are not comfortable with SASS, simply ignore that and make modifications to the .css file (in that case I suggest to delete the SASS file (.scss)).