For some record types with this type of relationship, Smart Document Templates and Barcode Templates in Infoplus can be set up to perform a rendering for each sub-record.
Create Smart Documents and Barcode Templates for sub-records (such as Order Lines, Eaches, or Fulfillment Pick Work)
Some record types in Infoplus have natural "sub-records" under them. For example, the Line Items are sub-records of an Order, and Orders are sub-records of a Fulfillment Process. For some record types with this type of relationship, Smart Document Templates and Barcode Templates in Infoplus can be set up to perform a rendering for each sub-record. You can use this feature to create documents with pages for all lines on an order, or all orders in a process, to help drive your custom warehouse workflows. This article describes how to use this capability.
or an ASN/Order Line Each.
Configuring a Smart Document Template or Barcode Template
When creating a Smart Document Template or Barcode Template, if the Record Type chosen is Order, ASN, or Fulfillment Process, two additional fields are presented called Record Subtype and Subtype Sort.
The Record Subtype lets you choose a sub-type, based on the record type. This field is optional and if left blank, the template will be rendered only for the header record, like all other record types, but if you do choose a value in this field, then the template will be rendered for all sub-records under the header.
The Subtype Sort field lets you specify how the sub-types should be sorted (or ordered) when they are rendered. This field is optional and if left blank, a default order will be used, based on the Record Subtype.
Data Dictionary
Based on the Record Type & Record Subtype, different data are available to the template code. The $record and $parentRecord variables available for the template and script (if using a Script, with a Smart Document Template) will be different types of objects from the Infoplus API. This table provides the details on what is available based on the types selected:
Record Type | Record Subtype | $record | $parentRecord | Context for $recordCount and $totalCount | Smart Document / Barcode Template Example | Script Context |
Order | Line Item | orderLine | order | line items on the order |
Line Item Id: $record.sku<br /> Order No: $parentRecord.orderNo<br /> Line Item $recordCount of $totalCount<br /> |
order = The Order API object orderLineList = The list of Line Item API objects |
Order | Each | item | orderLine | eaches (1 through total quantity on the order) |
SKU: $record.sku<br /> Line Item Id: $parentRecord.id<br /> Order No: $parentRecord.orderNo<br /> Unit $recordCount of $totalCount<br /> |
order = The Order API object orderLineList = The list of Line Item API objects itemMap = a map of all Item API objects on the order where the SKU is the key |
ASN | Line Item | itemReceipt | asn | line items on the asn |
Item Receipt Id: $record.id<br /> PO No: $parentRecord.poNo<br /> Line $recordCount of $totalCount<br /> |
asn = The ASN API object lineItems = The list of Item Receipt API objects
|
ASN | Each | item | itemReceipt | eaches (1 through total quantity on the ASN) |
SKU: $record.sku<br /> Item Receipt Id: $parentRecord.id<br /> Unit $recordCount of $totalCount<br /> |
asn = The ASN API object lineItems = The list of Item Receipt API objects itemMap = a map of all Item API objects on the ASN where the SKU is the key
|
Fulfillment Processes | Order | order | fulfillmentProcess | orders in the process |
Order No: $record.orderNo<br /> Process No: $parentRecord.processNo<br /> Order $recordCount of $totalCount<br /> |
fulfillmentProcess = The Fulfillment Process API object orderList = The list of Order API objects |
Fulfillment Processes | Item | item | fulfillmentProcess | items in the process |
SKU: $record.sku<br /> Process No: $parentRecord.processNo<br /> Order $recordCount of $totalCount<br /> |
fulfillmentProcess = The Fulfillment Process API object orderList = The list of Order API objects itemMap = a map of all Item API objects in the process where the SKU is the key |
Fulfillment Processes | Line Item | orderLine | fulfillmentProcess | line items across all orders in the process |
SKU: $record.sku<br /> Order No: $record.orderNo<br /> Process No: $parentRecord.processNo<br /> Order $recordCount of $totalCount<br /> |
fulfillmentProcess = The Fulfillment Process API object orderList = The list of Order API objects orderLineMap = a map of all Order Line API objects in the process where the Order Line id is the key |
Fulfillment Processes | Each | item | orderLine | eaches (1 through total quantity in the process) |
SKU: $record.sku<br /> Order No: $parentRecord.orderNo<br /> Unit $recordCount of $totalCount<br /> |
fulfillmentProcess = The Fulfillment Process API object orderList = The list of Order API objects orderLineMap = a map of all Order Line API objects in the process where the Order Line id is the key itemMap = a map of all Item API objects in the process where the SKU is the key |
Fulfillment Processes | Pick Work | work | fulfillmentProcess | picks in the process |
Pick Location Address: $record.sourceLocation Pick SKU: $record.workProductList.get(0).sku<br /> |
fulfillmentProcess = The Fulfillment Process API object orderList = The list of Order API objects itemMap = a map of all Item API objects in the process where the SKU is the key workMap = a map of all Work API objects in the process where the work id is the key |
Common Variables for All Types
In addition to the per-record-type variables detailed above, the following objects are also available for all types:
Name | Description | Example |
$scriptOutput | Data generated by a script, for use by the template. (Smart Document Templates only). The object is of type Java Map. | <b>My Value: $scriptOutput.get("myValue")</b> |
$utils | Object with methods:
Barcodes are generated using BarcodeFactory. Full documentation is available here: http://barbecue.sourceforge.net/apidocs/net/sourceforge/barbecue/BarcodeFactory.html |
Order Barcode: <img src="$utils.generateBase64Barcode($record.orderNo.toString())" width="300" height="100" /> UPC: <img src="$utils.generateBase64Barcode('UPCA', $record.upc)" width="300" height="100" /> |
NOTE: To add a GS1 style barcode (GS1-128), click here
Using Scripts
Additional data can be made available to a Smart Document Template by associating a Script with the record, using the Script field on the Add/Edit Smart Document Template screen. The script associated with a Smart Document Template is executed once before any pages for the document are rendered. Such scripts have access to a variable named output, of type java.util.Map, where data can be put, and can then be accessed by a Template.
outputSkipping Records
You can skip a particular record (i.e., cause it to not produce a page in the resulting PDF), by using a Script with your Smart Document Template, and calling the method utils.addSubRecordToSkip(recordId) for any record which should be skipped. Note that if all sub-records in a particular run are skipped, Infoplus will produce a single page stating that all records have been skipped by the script (rather than a missing PDF).
The recordId for all Record Subtypes is the id attribute of the record - with the exception of the Order, in which case it is orderNo.
For example, if you are producing custom documents for your orders, but only need to do so if the order has a customerOrderNo on it in Infoplus, you could use a script like the following:
Using Scripts
Additional data can be made available to a Smart Document Template by associating a Script with the record, using the Script field on the Add/Edit Smart Document Template screen. The script associated with a Smart Document Template is executed once before any pages for the document are rendered. Such scripts have access to a variable named output, of type java.util.Map, where data can be put, and can then be accessed by a Template.
Skipping Records
You can skip a particular record (i.e., cause it to not produce a page in the resulting PDF), by using a Script with your Smart Document Template, and calling the method utils.addSubRecordToSkip(recordId) for any record which should be skipped. Note that if all sub-records in a particular run are skipped, Infoplus will produce a single page stating that all records have been skipped by the script (rather than a missing PDF).
The recordId for all Record Subtypes is the id attribute of the record - with the exception of the Order, in which case it is orderNo.
For example, if you are producing custom documents for your orders, but only need to do so if the order has a customerOrderNo on it in Infoplus, you could use a script like the following:
for(var i=0; i<orderList.size(); i++){ if(!orderList.get(i).customerOrderNo) { utils.addSubRecordToSkip(order.orderNo) }}
A Note About Using the && Operator in Smart Documents
If you're having issues using the && operator in Smart Document templates, try putting them inside an HTML comment, like so:
<!-- #if($var1 && $var2) --> <div>test<div/><!-- #end -->