1. Knowledge Base
  2. Getting Started
  3. Step 10: Warehouse Documents and Printing

How to Add Order Line Descriptions to a Smart Document

Add a description to your packing slip smart documents by utilizing this example script.

Use Case: 

You are trying to add the description to your Packing Slip Smart Doc based on the line items but your value continues to not populate. How do you get Order Line descriptions to populate in a Smart Doc?

Solution:

  1. Create a Script
    1. Type: Smart Document
  2. Sample Script:
///////////////////////////////////////////

// fetch all items for those order lines //

///////////////////////////////////////////

var skuList = [];

for(var i=0; i<order.lineItems.size(); i++)

{    

   skuList.push(order.lineItems.get(i).sku);

}

var filter = "sku in ('" + skuList.join("','") + "')";

utils.log("Searching for items with [" + filter + "]");

var itemList = infoplusApi.search("item", filter, null, 250, null);

/////////////////////////////////////////////////////////////////////////////////

// now create a map where the sku yields the item description for the smartDoc //

/////////////////////////////////////////////////////////////////////////////////

var itemMap = {};

for(var i=0; i<itemList.size(); i++)

{    

   var item = itemList.get(i);    

   utils.log("Found item [" + item.sku + "]");    

   itemMap["sku"+item.sku] = item.itemDescription;

}




output.put("itemMap", itemMap);

 

3. Update your Smart Doc Template:
<tr>

<td>&nbsp;</td>

<td><strong>IN THIS SHIPMENT</strong></td>

<td>&nbsp;</td>

<td>&nbsp;</td>

</tr>

<!--

         #foreach($lineItem in $record.lineItems)

-->

<tr>

<td>$lineItem.shippedQty</td>

<td>$scriptOutput.itemMap.get("sku$lineItem.sku")</td>

<td>$lineItem.sku</td>

</tr>

<!-- #end -->

 

Output:

 

This is based on the Sample Smart Document script in Sample Smart Document Templates