2

We are using NetSuite's Advanced PDF Template for Grouped Invoices to print groups of invoices and need to include an existing custom field (custbody_subscription_name from the invoice header) on each invoice row in the invoice group.

enter image description here

We can add the custom field to the view in the Invoice Group app, but how do we reference the customized field in the PDF template? The template appears to use a hardcoded name 'groupedinvoices_summary' to refer to each group of invoices, but it's unclear how to reference a custom field. Here's a snippet of our customized HTML template with our 'custbody_subscription_name' custom field:

<table style="width: 100%; margin-top: 10px;"><#list groupedinvoices_summary as invoice><#if invoice_index==0>
<thead>
<tr style="background-color: #d3d3d3;">
<td align="center" colspan="4" style="font-weight: bold;border-left: 1px solid; border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.custbody_subscription_name@label}</td>
<td align="center" colspan="4" style="font-weight: bold;border-left: 1px solid; border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.invoicenum@label}</td>
<td align="center" colspan="3" style="font-weight: bold;border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.itemtotal@label}</td>
<td align="center" colspan="3" style="font-weight: bold;border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.discounttotal@label}</td>
<td align="center" colspan="3" style="font-weight: bold;border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.trantaxtotal@label}</td>
<td align="center" colspan="3" style="font-weight: bold;border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.shippingcharge@label}</td>
<td align="center" colspan="3" style="font-weight: bold;border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.handlingcharge@label}</td>
<td align="center" colspan="3" style="font-weight: bold;border-top: 1px solid; border-bottom: 1px solid; border-right: 1px solid ">${invoice.fxamount@label}</td>
</tr>
</thead>
</#if><tr>
<td align="left" colspan="4" style="color: #333333;border-left: 1px solid; border-bottom: 1px solid; border-right: 1px solid">${invoice.custbody_subscription_name}</td>
<td align="left" colspan="4" style="color: #333333;border-left: 1px solid; border-bottom: 1px solid; border-right: 1px solid">${invoice.invoicenum}</td>
<td align="center" colspan="3" style="border-bottom: 1px solid; border-right: 1px solid">${invoice.itemtotal}</td>
<td align="center" colspan="3" style="border-bottom: 1px solid; border-right: 1px solid">${invoice.discounttotal}</td>
<td align="center" colspan="3" style="border-bottom: 1px solid; border-right: 1px solid">${invoice.trantaxtotal}</td>
<td align="center" colspan="3" style="border-bottom: 1px solid; border-right: 1px solid">${invoice.shippingcharge}</td>
<td align="center" colspan="3" style="border-bottom: 1px solid; border-right: 1px solid">${invoice.handlingcharge}</td>
<td align="right" colspan="3" style="border-bottom: 1px solid; border-right: 1px solid">${invoice.fxamount}</td>
</tr>
</#list></table>

UPDATE #1: After trying various approaches the main issue is that, apparently, only fields in the default views can be referenced. How do we work around this?

A2MetalCore
  • 1,621
  • 4
  • 25
  • 49

1 Answers1

2

You can add data to an Advanced PDF template in SuiteScript using the TemplateRenderer.addCustomDataSource() method.

var invoiceGroupInvoiceReportRows = { groupedinvoices_summary: [<your data>] };
var invoiceDetailReportRows = { invoice_details: [<your data>] };
xmlReport.addCustomDataSource({
    format: render.DataSource.OBJECT,
    alias: 'results',
    data: invoiceGroupInvoiceReportRows
});

Then reference that data in the report XML like this:

results.groupedinvoices_summary

Refer to Suite Answers 82586, 49339, and 44622 for more information/

Martha
  • 731
  • 3
  • 9