Blog

Tips, Tricks & Workarounds : Printing the Lot Number’s Expiration Date using Advanced PDF Templates

Background : One of our clients needed to be able to print the Expiration Date of a Lot Numbered item along with the Lot Number on Invoices and Packing Slips. While the Lot Number and Bin Number are easily accessible using Advanced PDF templates, the Expiration Date is not. Even though the subrecord displays the expiration date in the UI, this is unavailable to print in the PDF template. One possible solution is to script the print action, but we used a relatively easier alternative – a combination of a custom field, a small user-event script, and a little bit of custom freemarker code on the template. The ability to do this without the workaround may be included in release 2016.1, but as of 2015.2 this, or similar, workaround was required to print expiration dates.

Solution : Directly accessing the expiration date of a lot numbered item might be difficult from the subrecord on the transaction line, but if we surface the information out of the subrecord into a custom field on the line then it’s easy to print.

  • We created a custom transaction column field, of type free-form text, into which we populated a concatenated string value of lot number, expiration date, and quantity.
  • This field’s value was populated by a user event script that executed upon saving the transaction record.

For example, if a line item on an order had the lot number Q12345 with corresponding expiration date 12/22/17, and the ordered quantity was 25, the custom field on that line would have a value Q12345,12/22/17,25; Multiple lot numbers on the same line would result in concatenated string values separated by a semi-colon (;). For example – Q12345,12/22/17,25;P09876,11/15/17,30;

Once we are able to surface the expiration date and other required information at the line-level on a transaction, getting this to print using an Advanced PDF template requires a fairly simple bit of freemarker code.

<#list item.custcol_invdetail_text?string?split(“;”) as inv>
<#if inv?has_content>
<tr>
<#list inv?split(“,”) as details>
<td style=”font-size:8pt”>${details}</td>
</#list>
</tr>
</#if>
</#list>

1

 

Adding this to the PDF template right after the section to print the line items will result in the Lot Number, Expiration Date and quantity being printed in separate columns.