Configure to display order line item information on invoices
If you are using the Order Line Items feature, you can configure HTML templates to display information about the Order Line Item object and its fields, including custom fields. All fields of the Order Line Item object are available when you access this object through the Invoice Items object.
Display order line item information on invoices
Assume that you want to display the values of the following fields of the Order Line Item object in the charge details table of invoices:
- AmountPerUnit
- Amount
- Description
- custom_field__c
To configure HTML templates to display information about order line items on invoices, perform the following steps:
- Create an HTML invoice template where you choose the starter template called Basic from the invoice template library.
- In the online HTML template editor, click the Data Table block for the charge details table.
The Content panel is displayed on the right of the template editor. -
In the Columns subsection of the Data Table section, click +Add in the Header column.
- In the Add Column dialog that is displayed, configure the following column information to add a column to display the amount per unit:
- From the Field list, OrderLineItem: OrderLineItem, and then select AmountPerUnit that belongs to the OrderLineItem object from the displayed drop-down list.
- In the Header field, enter OLI Amount Per Unit as the header name for the selected field to display in the data table.
- Click Add to save the column information.
A column with the OLI Amount Per Unit header is added to the data table.
- In the Add Column dialog that is displayed, configure the following column information to add a column to display the amount per unit:
- From the Field list, OrderLineItem: OrderLineItem, and then select Amount that belongs to the OrderLineItem object from the displayed drop-down list.
- In the Header field, enter OLI Amount as the header name for the selected field to display in the data table.
- Click Add to save the column information.
A column with the OLI Amount header is added to the data table.
- In the Add Column dialog that is displayed, configure the following column information to add a column to display the amount per unit:
- From the Field list, OrderLineItem: OrderLineItem, and then select Description that belongs to the OrderLineItem object from the displayed drop-down list.
- In the Header field, enter OLI Description as the header name for the selected field to display in the data table.
- Click Add to save the column information.
A column with the OLI Description header is added to the data table.
- In the Add Column dialog that is displayed, configure the following column information to add a column to display the amount per unit:
- From the Field list, OrderLineItem: OrderLineItem, and then select custom_field__c that belongs to the OrderLineItem object from the displayed drop-down list.
- In the Header field, enter OLI Custom Field as the header name for the selected field to display in the data table.
- Click Add to save the column information.
A column with the OLI Custom Field header is added to the data table.
- In the HTML template editor, click Save to save the HTML template.
- Click Preview to switch to the Preview mode to preview an invoice using the HTML template.
The displayed HTML template changes to an invoice PDF file with actual data for you to preview. If an invoice item is generated from an order line item, information about the order line item is displayed in the associated column of the corresponding invoice item row.
If an invoice item is not created from any order line item, information is displayed blank for the corresponding invoice item.
Group order line items
You can use the GroupBy
function to group order line items in HTML templates. For more information about the GroupBy
function, see Use GroupBy function.
Assume that you want to display order line item information on debit memos and order line items grouped by their Sold To Contact.
To configure HTML templates to group order line items by their Sold To Contact on debit memos, perform the following steps:
- Create an HTML template where you choose the starter template called Basic from the debit memo template library.
- In the online HTML template editor, click the HTML block for the charge details table.
The Content panel is displayed on the right of the template editor. -
In the HTML section, enter the HTML source code into the HTML editor, and modify the code as follows.
{{#DebitMemo}} <!-- Group order line items by sold to contact --> {{#DebitMemoItems|Map(InvoiceItem)|Uniq|FilterByValue(SourceItemType,EQ,OrderLineItem)|GroupBy(OrderLineItem.SoldTo)}} {{Cmd_Assign(ByOrderLineItemSoldTo,_Group)}} <!-- Not display sold to contact and table header if the group is empty --> {{#ByOrderLineItemSoldTo|First(1)}} <!-- The merge field path is InvoiceItem.Invoice.Account --> {{#Invoice.Account.Contacts|FilterByRef(Id,EQ,OrderLineItem.SoldTo)}} <div style="background-color:grey;"> <b>Shipped To: </b>{{FirstName}} {{LastName}}, {{Address1}} {{Address2}}, {{City}}, {{State}} {{PostalCode}} </div> {{/Invoice.Account.Contacts|FilterByRef(Id,EQ,OrderLineItem.SoldTo)}} <table class="table-grid u_content_custom_generic_table_1"> <thead><tr> <th style="width:auto; "> SKU </th> <th style="width:auto; "> ChargeName </th> <th style="width:auto; "> Service Period </th> <th style="width:auto; "> Backorder Qty </th> <th style="width:auto; "> Shipped Qty </th> <th style="width:auto; "> UOM </th> <th style="width:auto; "> UnitPrice </th> <th style="width:auto; "> ChargeAmount </th> </tr> </thead> <tbody> {{/ByOrderLineItemSoldTo|First(1)}} <!-- Loop the group --> {{#ByOrderLineItemSoldTo}} <tr> <td style=" ">{{SKU}}</td> <td style=" ">{{ChargeName}}</td> <td style=" ">{{ServiceStartDate|Localise}} - {{ServiceEndDate|Localise}}</td> <td style=" ">{{OrderLineItem.QuantityPendingFulfillment}}</td> <td style=" ">{{OrderLineItem.QuantityFulfilled}}</td> <td style=" ">{{UOM}}</td> <td style=" ">{{UnitPrice}}</td> <td style="text-align:right; ">{{ChargeAmount|Round(2)|Localise}}</td> </tr> {{/ByOrderLineItemSoldTo}} </tbody> </table> <br/> {{/DebitMemoItems|Map(InvoiceItem)|Uniq|FilterByValue(SourceItemType,EQ,OrderLineItem)|GroupBy(OrderLineItem.SoldTo)}} {{/DebitMemo}}
- In the HTML template editor, click Save to save the HTML template.
- Click Preview to switch to the Preview mode to preview a debit memo using the HTML template.
The displayed HTML template changes to an invoice PDF file with actual data for you to preview. If a debit memo item is generated from an order line item, information about the grouped order line item is displayed in the associated column of the corresponding debit memo item row.
If a debit memo item is not created from any order line item, information is displayed blank for the corresponding debit memo item.