listfreemarkernetsuitesublistbfo

Sublist in Netsuite PDF/HTML Template


I have a credit memo template for which I want to include what invoices this credit has been applied to (This information is in a sublist on the record under ITEM > Apply )

I currently have the below code in the template, which only seems to show the first invoice in the sublist?? I can't figure why.

    <#if record.apply?has_content>

<table>
<thead><tr><th>Applied to:</th></tr></thead></table>
<table><#list record.apply as apply><#if apply_index==3>
<thead>
    <tr>
    <th style="align: center;">Date</th>
    <th style="align: center;">Invoice</th>
    <th style="align: center;">Original Amount</th>
    <th style="align: center;">Payment</th>
    <th style="align: center;">Due</th>
    </tr>
</thead><tr>
    <td style="align: center;">${apply.duedate}</td>
    <td style="align: center;">${apply.refnum}</td>
    <td style="align: center;">${apply.total}</td>
    <td style="align: center;">${apply.amount}</td>
    <td style="align: center;"><#assign remaining=(apply.total)-(apply.amount)>${remaining?string.currency}</td>
    </tr></#if></#list>
    </table></#if>

I don't have access to any suitescript or serverscript or anything like that, so I need a solution to the source code in the PDF/HTML Template (if possible)


Solution

  • You have <#if apply_index==3>, this is only ever true once. It should be <#if apply_index==0> and that should end after defining the thead.

    The rest of the list loop should be as is. The problem is your if statement. It's typically used to only create the header at index 0. The rest of the tbody is produced outside of the if statement and inside the list loop.

    Since your header is 100% static typed, you do not need the if statement at all. You should only have the TR sections within the TBODY within your list loop.

    <#if record.apply?has_content>
        <table>
            <thead><tr><th>Applied to:</th></tr></thead></table>
            <table>
                <thead>
                <tr>
                    <th style="align: center;">Date</th>
                    <th style="align: center;">Invoice</th>
                    <th style="align: center;">Original Amount</th>
                    <th style="align: center;">Payment</th>
                    <th style="align: center;">Due</th>
                </tr>
            </thead>
            <tbody>
                <#list record.apply as apply>
                <tr>
                    <td style="align: center;">${apply.duedate}</td>
                    <td style="align: center;">${apply.refnum}</td>
                    <td style="align: center;">${apply.total}</td>
                    <td style="align: center;">${apply.amount}</td>
                    <td style="align: center;"><#assign remaining=(apply.total)-(apply.amount)>${remaining?string.currency}</td>
                </tr>
                </#list>
            </tbody>
        </table>
    </#if>