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 setup 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 ordering 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 TypeRecord Subtype$record$parentRecordContext for $recordCount and $totalCountSmart Document / Barcode Template ExampleScript Context
OrderLine ItemorderLineorderline 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 

OrderEachitemorderLineeaches (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


ASNLine ItemitemReceiptasnline 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



ASNEachitemitemReceipteaches (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 ProcessesOrderorderfulfillmentProcessorders 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 ProcessesItemitemfulfillmentProcessitems 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 ProcessesLine ItemorderLinefulfillmentProcessline 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 ProcessesEachitemorderLineeaches (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 ProcessesPick WorkworkfulfillmentProcesspicks 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:

NameDescriptionExample
$scriptOutputData 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>
$utilsObject with methods:
  • generateBase64Barcode(value) (defaults to type CODE_128B)
    • This is the a simple method to generate a barcode in type Code 128B.  


  • generateBase64Barcode(barcodeType, value) 
    • This method allows you to specify the barcode type to be produced.    
    • barcodeType must be one of the following:
      • 'CODE_128B', 'UPCA', 'EAN_128', 'CODE_128', 'SCC14_SHIPPING_CODE', 'TWO_OF_SEVEN', 'BOOKLAND', 'CODABAR', 'CODE_128A', 'CODE_128C', 'EAN_13', 'GLOBAL_TRADE_ITEM_NUMBER', 'INT_2_OF_5', 'MONARCH', 'NW7', 'PDF_417', 'POST_NET', 'RANDOM_WEIGHT_UPCA', 'SHIPMENT_IDENTIFICATION_NUMBER', 'SSCC18', 'STD_2_OF_5', 'USD_4', 'USPS', 'THREE_OF_NINE', 'CODE_39', or 'USD_3'


  • generateBase64Barcode(barcodeType, value, barHeight, barWidth, resolution, doCheck)
    • This method provides the most customization of the barcode, with the following parameters:
      • barcodeType - String - see above.
      • value - String - value to represent as the barcode.  Note,  if you are trying to use a numeric variable, you may need to call .toString() the variable.  
      • barHeight - Optional Integer representing how many pixels tall each bar in the barcode is.
      • barWidth - Optional Integer representing how wide the smallest bar in the barcode is in pixels.
      • resolution - Optional IInteger representing the output resolution in dots per inch.  
      • doCheck - boolean indicating that a check digit should be computed by the function.  Only supported for barcodeTypes:  STD_2_OF_5, INT_2_OF_5, THREE_OF_NINE, CODE_39, USD_3, CODE_128B


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" /> 



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 access by a Template.  


Skiping 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 -->