FreeMarker Functions in the Template Utility

This table lists the FreeMarker functions used in the WD_GridOE_TemplateUtils.xml template utility file. This file is located in the SuiteBundles > Bundle 41296 > src > GridPrinting folder on the File Cabinet.

Before using other functions, you must first call getItemDetails or getItemOrderedShippedQty functions. Other functions in the utility file depend on the item details in the JSON data.

You can find the following FreeMarker functions in the utility file when you create custom grid print templates.

FreeMarker Function

Parameters

Description

Sample

min(val1, val2)

val1, val2 – compares numeric values

This function returns the lower value between parameters val1 and val2.

FTL:

<#assign test = min(1,9)> {test}

Output:

1

getItemDetails(items)

items – accepts record.item, which is the current transaction’s item list

This function traverses through the item lines in the transaction. Then this function returns a JSON data with the following pattern:

{<item.itemid>: {rate:<item.rate>,quantity: <item.quantity>}}

The JSON data stores the same items with collated quantities. If the item rates differ, the JSON data stores the rate of the item’s latest entry.

record.item:

-[{itemid: 10, rate: 10, quantity: 10},

{itemid: 20, rate: 20, quantity: 20}.

{itemid: 10, rate: 30, quantity: 30}]

FTL:

{getItemDetails(record.item)}

Output:

{10: {rate: 30, quantity: 40}

20: {rate: 20, quantity: 20}}

getItemOrderedShippedQty(salesorder, items)

salesorder – corresponding sales order or transfer order transaction record of the current item fulfillment

items – accepts record.item, which is the current transaction's item list

You can use this function in packing slips.

This function traverses through the item lines in the current sales order or transfer order related to the item fulfillment. Then, this function returns a JSON data with the following pattern:

{itemid: {ordered: <SO.quantity>, shipped: <IF.quantity>, backorder: <SO.backordered>}}

The JSON data stores only the items found in both item fulfillment and sales order or transfer order transactions. The JSON data also stores the same items with collated quantities, shipped quantities, and backordered quantities.

salesorder.item:

-[{itemid: 10, rate: 10, quantity: 10, backordered: 10},

{itemid: 20, rate: 20, quantity: 20, backordered: 0}.

{itemid: 10, rate: 30, quantity: 30, backordered: 0}]

record.item: (IF)

-[{itemid: 10, quantity: 5}]

FTL:

{getItemOrderedShippedQty(salesorder, record.item)}

Output:

{10: {ordered: 40, shipped: 5, backorder: 10}}

getRowColLabel(gridData)

gridData – grid data from record.custbody_gridoe_trantemplatedata

When the gridData.type is “MI”, the output returns the label stored in gridData.grid.rowcollabel.

When the gridData.type is not “MI”, the output returns “gridData.grid.rowlabel / gridData.grid.collabel”.

gridData[0]:

{type: "MI", grid: {rowcollabel: "Main Label", rowlabel: "Color", collabel: "Size"}}

gridData[1]:

{type: "", grid: {rowcollabel: "Main Label", rowlabel: "Color", collabel: "Size"}}

FTL:

{getRowColLabel{gridData[0]}}

{getRowColLabel{gridData[1]}}

Output:

"Main Label"

"Color / Size"

getRowColumnData(row, col, subcolumn)

row – accepts gridData.grid.data element

col – accepts gridData.grid.data.columnids element

subcolumn – accepts subcolumns (Rate, Qty)

The loop for gridData.grid.data that traverses the rows and columns must call this function.

This function gets the corresponding subcolumn data for the current row and column of the loop from itemDetails.

When subcolumn is picked, the output returns blank. When subcolumn is rate, the output formats to currency 0.00.

itemDetails:

{10: {rate: 100, quantity: 999}}

FTL:

{getRowColumnData(row,col,rate)}

{getRowColumnData(row,col,quantity)}

{getRowColumnData(row,col,picked)}

Output:

100.00

999

""

getRowTotal(row, subcolumn)

row – accepts gridData.grid.data element

subcolumn – accepts subcolumns (Rate, Qty)

The loop for gridData.grid.data that traverses the rows and columns must call this function.

This function gets the corresponding subcolumn total for the current row of the loop from itemDetails.

gridData.grid.data:

{column01:{ internalid: 10},

column02: { internalid: 20}}

itemDetails:

{10: {rate: 100, quantity: 999},

20: {rate: 100, quantity: 1}}

FTL:

{getRowTotal(row, rate)}

{getRowTotal(row, quantity)}

Output:

200

1000

getColumnTotal (rows, column, subcolumn)

row – accepts gridData.grid.data

column – accepts gridData.grid.data.columnids element

subcolumn – accepts subcolumn (Rate, Qty)

The loop for gridData.grid.data.columnids that traverses the rows and columns must call this function.

This function gets the corresponding subcolumn total for the current column of the loop from itemDetails.

gridData[0].grid.data::

{column01:{ internalid: 10}}

gridData[1].grid.data:

{column01:{ internalid: 20}}

itemDetails:

{10: {rate: 100, quantity: 999},

20: {rate: 100, quantity: 1}}

FTL:

{getColumnTotal(rows, col, rate)}

{getColumnTotal(rows, col, quantity)}

Output:

200

1000

For information about the other elements included in Grid Print Templates, see the following topics:

Related Topics

General Notices