get data from child record(or hyper link) to print in netsuite advanced html pdf

1.8k Views Asked by At

I am new to netsuite and is working on creating a html template for invoice groups. The group has multiple invoices as lines and you can click on them and navigate to the actual invoice which has a lot more data.

I want to print the invoice group details and also show some data that is only available in the actual invoice level.

screenshot of invoices under invoice group

I can access the invoice number in the group like record.invoice_details.invoicenum but I want to get the data under this invoice which can be accessed like record.item.item_display if I am in the invoice screen. So I am looking for something like record.invoice_details.invoicenum.item_display where I start at the invoice group and make my way down to the invoice items.

Any help here is appreciated. DO let me know if you need any more info here.

Thanks in advance.

1

There are 1 best solutions below

2
On

Something like record.invoice_details.invoicenum.item_display would be considered a multi-level join which NetSuite does not support. I'm not sure what you meant by "to get the data under this invoice" but if it's a value stored on the record itself use the field id in record.invoice_details.FIELD_ID. If it is not on the record, you'll have to add it to the record (could be in a hidden field). Or you can create use SuiteScript to create a custom function. Reference Suite Answers 82586, 49137, and 44622

Via SuiteScript you can add data to an Advanced PDF template using the
"addCustomDataSource" method on the report object:

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:

<#list results.groupedinvoices_summary as invoice>
...
</#list>