To get all tracking numbers on an Item Fulfillment, you should account for all the possible tracking numbers. There are three that NetSuite uses:
transaction.packagetransaction.packageupstransaction.packagefedex
The actual tracking link is referenced in with FreeMarker like this:
<#list transaction.package as pkg>${pkg.packagetrackingnumber}</#list><#list transaction.packageups as pkg>${pkg.packagetrackingnumberups}</#list><#list transaction.packagefedex as pkg>${pkg.packagetrackingnumberfedex}</#list>
- I list each package tracking number and use the FreeMarker
?is_lasttag 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
ifstatement and reference theshipmethodfield 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}&brand=DHL">${pkg.packagetrackingnumber}</a>
<#else>${pkg.packagetrackingnumber}
</#if>
<#if pkg?is_last>
<#else>,
</#if>
</#list>