background

Add External UPS tracking numbers to an Order

Published on 14 March 2017 in salesforce tracking 

In today's blog post we’ll show you how to add externally created UPS tracking number to an object. Most common use cases are to get updated tracking, that you are then able to query using the standard Salesforce reporting. We will be using the Order object in our demo here.

 

Trigger on the Order Object:

Line 3: For when a brand new order is added with a tracking number

Line 6: For when the tracking number field is updated

 

The trigger Handler class:

This is where the work gets done.

Line 4: You will need to contact us to get the ModKey value that allows the creation of a Shipment Object (without actually going through our package for the shipment creation process).

Line 7-11: You need to create a custom setting to store the ID of the preference, so that when you move this code from your sandbox org to your production org, its easy to update the custom setting to your saved UPS preference.

Shipping Settings

Line 27-39: For any new Orders, create the new shipment with the zkups__MasterTrackingId__c and make sure its linked to your UPS Preference via the zkups__UPSShipmatePreference__c.

Line 40-63: If you are just updating the tracking number field (FB_Tracking_Numbers__c) on your Order, this lines take care of the shipment creation.

Line 67-69: If a shipment has been queued for insertion, then we insert the Shipments.

The @Test class, is needed for the code coverage to be able to deploy into production.

Any questions, please do not hesitate to contact us!