ANS-1371 · PRINTING, PDF & EMAIL TEMPLATES
How to Group Invoice Items by Custom Field or Description in NetSuite?
Learn to organize invoice line items into logical groups within NetSuite's Advanced PDF/HTML Templates using FreeMarker logic.
Short answer
Group invoice items in NetSuite Advanced PDF/HTML Templates by using FreeMarker logic. Iterate over items, grouping them by a custom column or the 'Description' field. Employ the `?sort_by` directive to sort items, then detect changes in the grouping field to create and print new groups, optionally summing amounts.
Scenario
Users often require invoices to display line items grouped by specific criteria, such as a custom column or the item's description, rather than a simple sequential list. This grouping enhances readability and organization for both internal records and customer-facing documents. The challenge lies in implementing this dynamic grouping within NetSuite's customizable invoice templates.
Solution
To implement item grouping on invoices within NetSuite's Advanced PDF/HTML Templates, FreeMarker logic is employed to iterate over the transaction's items.Groups can be formed based on a custom column defined on the item record or by using the item's 'Description' field.While the provided context does not include a specific code snippet, the approach involves using the FreeMarker built-in directive ?sort_by to organize the items.The FreeMarker code then detects changes in the chosen grouping field (e.g., 'Description') as it iterates through the sorted items. Upon detecting a change, a new group is created and printed.It is also possible to include logic within the template to sum amounts for items within each group as they are being built.
Expert NetSuite Support
Need help with this NetSuite issue?
Printing, PDF & Email Templates consulting and configuration support
