Dynamic table adds additional header without any detail rows


We have an invoice template that mostly goes fine but now I found a case where somehow an additional header is displayed but there are no detail lines left.
I would have expected the header to appear once, after each page break but here it appears twice on 1 page.

Here is my definition of the table:

<table id="INVOICELINES" class="tblhdrnopadding invstable" data-detail="INVOICELINES" width="100%">
            <td class="tblbottomline"><b>@hdrchgdescr@</b></td>
            <td class="tblbottomline" align="center"><b>@hdrunits@</b></td>
            <td class="tblbottomline" align="center"><b>@hdruname@</b></td>
            <td class="tblbottomline" align="center"><b>@hdrccy@</b></td>
            <td class="tblbottomline" width="65px" align="center"><b>@hdrunitrate@</b></td>
            <td class="tblbottomline" width="55px" align="right">
        <tr data-hide-when-empty="" data-show-row="all" data-repeat="INVOICELINES.InvoiceLine">
        <tr class="tblspacing tbldetails" data-show-row="all" data-repeat="INVOICELINES.InvoiceLine.Details">
            <td class="invspadding">@ChargeDescription@@txt1@@invref@</td>
            <td class="invspadding" align="center">@Units@</td>
            <td class="invspadding" align="center">@UnitName@</td>
            <td class="invspadding" align="center">@ccy@</td>
            <td class="invspadding" align="center">@UnitRate@</td>
            <td class="invspadding" align="right">@Amount@</td>

Does anyone know why the system does this?

Check if you do not have a empty line at the end of your input file

There is no empty line at the end of the input file. I use an XML as the input file and the header section appears only once in it.

Which version are you running?

Version 2022.1.4.10850

With the provided HTML I cannot reproduce the problem. Would you be able to share the template and datamapper (anonymized) via a direct message?

I just found out it has something to do with my post pagination script but I don’t know why. If I disable it then it will not happen. Unfortunately the top header of the invoice can be dynamic and so I want to calculate the height and then resize the top margin according to that.

It seems that in your template the .paginage() function is not behaving as intended. I created a quick workaround by counting the number of header tables before this function and compare the length after. See the script below. Suggest to reachout to our techsupport department and file a bug report.


let noInvoiceTables = query("#INVOICELINES").length;

let headerSize = ((query("#invoiceHeader").height() + query("#invoiceHeader2").height()) / 94) + 0.3;
merge.section.margins.top = headerSize.toString() + "in";

if ( query("#INVOICELINES").length > noInvoiceTables ) {

Thank you for your workaround. I logged a ticket for this issue.

No problem, hope we can find the root cause and solve it properly.

Hi I have encountered this issue as well with version v2023.

And Eriks script helped. This is my workaround.

query("[your dynamic table]").each(function(o,i){ 
	var tbodyVal = query("tbody",i).html().trim();
	if(tbodyVal=="") i.hide();

However if you have content after the table. Hiding the empty table will cause a shift in the position of the content. Also the more the document creates a new page, each page break creates that extra table (multiplies).

So this wont work for me :frowning: