You are here:
Print a Table with Dynamic List Data
To print and display each item from a dynamic list like order items, use the <each> node.
Required Editions
| Available in Lightning Experience in Enterprise and Unlimited Editions that have Consumer Goods Cloud enabled. |
You can use the each element to print the items of a
list object iteratively. For each item of a list object, the table row is defined within the
each element and is printed subsequently. For example,
to print an order containing a list of order items - create an each node. The each node iterates over a
certain datasource and a list object. For each list item or order item in the list, it appends
the tr node for all items in the list, and in the output, all order items are printed in a
table format.
The each element iterates based on the list object that
is set in the value attribute andcreates the rows for a
table using the tr and td elements. This attribute allows you to define the multiple variables that can
be extracted from the same list object specified in the value attribute.
The supported attributes are:
| Attribute | Description | Data Type | Required |
|---|---|---|---|
| name | Unique name of each tag. | String | Yes |
| value | Contains a binding that resolves to a list object. | String | Yes |
The supported child elements are:
| Attribute | Description | Required |
|---|---|---|
| tr | Contains a table row node that serves as a template for each list item in the list object. | — |
| filters | Filters the list items of the list object. | No |
| orderCriteria | Sort the list items of the list object. | No |
| correlation | Points to another list object which is then correlated with the list that’s used
in the When there is correlated data, the calculation engine fetches additional information about price changes for each product and shown in the order table. Ensure that the colspan value in the correlation row matches the total number of columns in the table. For example, if the table has four columns and the correlation row has only two columns, set the column span values so that their sum equals the total number of columns in the table. |
No |
value attribute of the each element references the macro
path {{Declarations::orderItems}} ( LO) that has the required properties. The
variables in the td element refers to the multiple properties that can be
extracted from the same list item of
LoOrderItems.<!-- left out details for brevity -->
<Declarations>
<DataDeclaration name="order" type="LuOrder" />
<DataDeclaration name="orderer" type="LuOrderer" />
<DataDeclaration name="recipient" type="LuRecipient" />
<DataDeclaration name="orderItems" type="LoOrderItems" />
</Declarations>
<!--Trimmed code -->
<tbody>
<each name="each1" value="{{Declarations::orderItems}}">
<tr>
<td>{{.id}}</td>
<td italics="true">{{.name}}</td>
<td>{{.unit}}</td>
<td>{{.quantity}}</td>
<td>{{.price; numberFormat=8.2}}</td>
<td>{{.total}}</td>
<td>{{.netTotal}}</td>
</tr>
</each>
</tbody>each node is defined to print the Empties report
by using the data extracted from loEmptiesForPrintout. The
tr element defines the data and the format that the print engine should
apply and replicate for each row of data in loEmptiesForPrintout to print in
the order.<!-- Empties Table -->
<tbody>
<each name="emptiesEach" value="{{Declarations::order.loEmptiesForPrintout}}">
<orderCriteria>
<orderCriterion fieldName="prdId" direction="ASC" />
</orderCriteria>
<tr>
<td>{{.prdId}}</td>
<td>{{.text1}}</td>
<td alignment="right">{{.quantityDelivered}}</td>
<td alignment="right">{{.quantityReturned}}</td>
<td alignment="right">{{.totalQuantity}}</td>
<td alignment="center">{{.taxClassification}}</td>
</tr>
</each>
<tr>
<td colSpan="4" alignment="right">{{Labels::SumEmptiesLabelId; defaultLabel=Total Empties}}</td>
<td alignment="right">
<sum table="EmptiesTable" col="4" />
</td>
</tr>
</tbody>each element references the macro
path {{Declarations::order.loPrintItems}} that is a list object containing
the print items for this order. So, for all the order values – for each of the entries – there
is a row in this list object. The print engine prints the tr with a set of 8 cells and repeats
the action for each row in the list order.<tbody>
<each name="itemsEach" value="{{Declarations::order.loPrintItems}}">
<filters>
<filter fieldName="quantity" value="0" operator="GT" compareMode="NUMBER" />
<filter fieldName="movementDirection" value="In" operator="NE" />
</filters>
<orderCriteria>
<orderCriterion fieldName="prdId" direction="ASC" compareMode="NUMBER" />
</orderCriteria>
<tr>
<td>{{.prdId}}</td>
<td>{{.text1}}</td>
<td alignment="center">{{.quantityLogisticUnit; toggleId=DomPrdLogisticUnit; toggleField=shortText}}</td>
<td alignment="right">{{.quantity}}</td>
<td alignment="right">{{.basePriceReceipt; numberFormat=8.2}}</td>
<td alignment="right">{{.grossValueReceipt; numberFormat=8.2}}</td>
<td alignment="right">{{.valueReceipt; numberFormat=8.2}}</td>
<td alignment="center">{{.taxClassification; toggleId=DomTaxClassification; toggleField=shortText}}</td>
</tr>
<correlation name="correlation1" value="{{Declarations::order.loSdoConditions}}" key="pKey" correlationKey="sdoItemPKey">
<filters>
<filter fieldName="sdoItemPKey" value=" " operator="NE" />
<filter fieldName="cpIsPrintRelevant" value="1" operator="EQ" />
</filters>
<tr>
</td>
<td italics="true" colSpan="7">{{path=.text1}} {{.conditionValue; numberFormat=8.2}} {{.conditionResult; numberFormat=8.2}}</td>
</tr>
</correlation>
</each>
</tbody>
