Tracking numbers on an Item Fulfillment

To get all tracking numbers on an Item Fulfillment, you should account for all the possible tracking numbers. There are three that NetSuite uses:

  1. transaction.package
  2. transaction.packageups
  3. transaction.packagefedex

The actual tracking link is referenced in with FreeMarker like this:

  1. <#list transaction.package as pkg>${pkg.packagetrackingnumber}</#list>
  2. <#list transaction.packageups as pkg>${pkg.packagetrackingnumberups}</#list>
  3. <#list transaction.packagefedex as pkg>${pkg.packagetrackingnumberfedex}</#list>
  • I list each package tracking number and use the FreeMarker ?is_last tag to determine if this is the last tracking number (so put a period) or if there are more (so put a comma and space). This logic isn’t perfect, since you might list UPS packages and come to the end and not put a space and then list Fedex packages and you’d have the first Fedex link right next to the last UPS link. I guess you could say this assumes only one carrier is used per fulfillment 🙂
  • For the non-UPS, non-Fedex links, I use an if statement and reference the shipmethod field to determine what the link should be.
  • I’ve auto-formatted the code for readability, but you can obviously remove newlines/whitespace to get the paragraph to show properly.

We have made a shipment against your PO ${transaction.createdfrom.otherrefnum}, with tracking number(s) <#list
    transaction.packagefedex as pkg> <a
        href="https://www.fedex.com/fedextrack/?trknbr=${pkg.packagetrackingnumberfedex}">${pkg.packagetrackingnumberfedex}</a>
    <#if pkg?is_last>
        <#else>,
    </#if>
</#list>
<#list transaction.packageups as pkg><a
        href="https://www.ups.com/track?tracknum=${pkg.packagetrackingnumberups}">${pkg.packagetrackingnumberups}</a>
    <#if pkg?is_last>
        <#else>,
    </#if>
</#list>
<#list transaction.package as pkg>
    <#if transaction.shipmethod?contains("DHL")><a
            href="https://www.dhl.com/en/express/tracking.html?AWB=${pkg.packagetrackingnumber}&amp;brand=DHL">${pkg.packagetrackingnumber}</a>
        <#else>${pkg.packagetrackingnumber}
    </#if>
    <#if pkg?is_last>
        <#else>,
    </#if>
</#list>

Leave a comment

Your email address will not be published. Required fields are marked *