Zenkraft Blog

Zenkraft Blogs about Logistics, LSPs, Integration with CRM, ERP and WMS applications.

How to Create a Shipment off a Trigger on Salesforce

Published on 06 December 2016 by in salesforce 

Here we will show you how you can create a shipment directly via a trigger on your Account object. For this example we will use our UPS app with our ShipAutomate product.

First, set up a trigger on your account object. This trigger will run each time the account is updated.


The trigger calls this apex class “AccountTriggerHandler”. The full code can be found here, but we will walk through it further down:


  1. First thing we need to do is get the UPS Shipment Preference and the associated preference details needed to create a shipment. We just select the top preference as we are only going to be using one preference on our test org.


  1. To support the Salesforce bulk process, we need to create a bulk shipment map to store Accounts and Zenkraft bulk shipments. For example, if we update a list of Accounts in Salesforce, this code below ensures that all Accounts generate a shipment.


  1. The next step is to create our queued shipment objects. This is the main section of our code and where we set all the ship to/ship from and service type details. Line 6, determines the “Service Type” and Line 9 is the “Packaging Type”.

    As the Account is a standard object, all we have to do to link the shipments generated to the account is to add this line of code: queuedShipment.zkups__Account__c = accountId; (as you can see in line 10 below).


  1. After created all the queued shipments, we are able to go to the next step, which is creating a new list of packages for each of the queued shipments. We add a package with a value of $100 and a weight of 2 pounds for each queued shipment.


  1. Final step, we loop through the bulk shipment list and call the ‘processBulkShipment‘ method to create the shipment:


Continue reading »

Part 2 of 3: Pick and Pack station on Salesforce – Custom Labels and Packing Slips

Published on 29 November 2016 by in salesforce 

Last week we wrote a first post on how we created a Pick and Pack station on Salesforce. In that post we’ve covered UI, scanning barcodes and integrating weights and scales. Today we’re focused on label generation and custom printing.

  1. Labels


  • And how it looks once printed out:
  • The quickest way to test your ZPL coding is to load your code into, and press the Redraw button, it will then show you what the label will look like once printed out.
  1. Custom printing
    • By Using our Zenkraft Printing app we were able to send jobs to the pre-defaulted printers based on user actions. Here is some example code to show how we can send labels for printing:


  • In the code above, we can see that ‘line 18’ sends the label for printing, where “this.labelId” is the attachment id of the salesforce object where the label resides.
  • For example, once a box was packed successfully and the user set the box as closed, we automatically sent two print commands; one to the thermal label printer to print out the content label (we mentioned in the previous post), and secondly we send the command to the laser printer to print out the packing slip (our PDF page).
  • Hopefully in the future HTML5 will support native browser printing, but until then our desktop app works great for automating print jobs from the browser.

Continue reading »

Part 1 of 3: How we created a Pick and Pack station on Salesforce

Published on 22 November 2016 by in salesforce 

Recently, we built a Pick and Pack station inside Salesforce for one of our customers. We really believe in the potential value it can add to user interactions, which is why we’ve decided to share pieces of how this could work for your business. We’ve created two blog posts to explain how this works. It is also worth mentioning that this can integrate with any ERP system you may already be using on Salesforce.

In this first post, we’ll be discussing: UI, scanning barcodes and weights & scales.

  1. UI
    1. We start by typing in a sales order number (custom object), or selecting a previously open one.
  1. Once on the ‘New Shipment’ screen, you can select the container size to use
  1. You can then start adding the products to pack into the container using a barcode scanner. The barcode scanner extracts the text representation of the barcode and adds it to the input box. We then do a search for that custom field in the products list and confirm its the required product. Once satisfied that everything is in order, we add the product to the container, otherwise we show an error message to that effect.
  2. Each time an item is scanned (packed), the “Total left to pack” column in the “Item to pack” line gets automatically updated. In the screenshot below you can see that we have 1 container in progress and we have packed one of ‘Item A’ and one of ‘Item B’.
  1. The next step is to “Finish container”. This will get the weight of the container (from the scales connected via our desktop app) and create a packing slip in PDF format that list items in that container.
  2. Once the containers for that shipping session have been completed, the user is able to click the Finish button. This will take into account all the shipping options such as the Service Type (Ground, Next Day Air etc etc), the weight of the containers and the dimensions, and will generate the correct shipping label.
  3. Implementing Scanning Barcodes
    • We used the javascript below, which is a combination of a few implementations, to help us with barcode scanning. We tested around 10 different libraries and found that the one we chose  worked the best across a multitude of devices.
  5. Weights & Scales
    • We have a separate interface for connecting your scales to your salesforce instance. Very similar to the standard printing management screens. It’s an API call to our desktop app that allows us to get the raw weight from the USB device that we then use to add to the shipment container.

In next week’s post, we’ll be discussing how you can create custom labels and auto print shipping labels in Salesforce®.

Continue reading »

New UPS version 3.10 Released

Published on 17 November 2016 by in ups salesforce 

We’ve been working on our UPS app and added some new great features based on your feedback:

  • Added ability to edit package profiles
  • Delivered to” and “Signed For By” Tracking Information added to shipment object
  • 3 address lines now available for shipment destinations
  • Phone number format maintained through One Click Shipping
  • One Click Shipping to allow “Use Contact Address” via opportunity objects
  • Custom setting added to enforce preference details when sending labels via email
  • Custom Setting added to disable creating an activity line when sending emails
  • Custom Setting added to allow Company name to be truncated to 35 characters (UPS limit)
  • Commercial Invoices now have “Additional Comments” section
  • Updated Mail Innovation logic for First and Priority
  • Fixed typo for Mail Innovation BPM Flat
  • Minor bug fixes

See Docs for all UPS Release Notes

Continue reading »

Adding Twilio Voice to your Salesforce Logistics Operation

Published on 15 November 2016 by in ecommerce salesforce 


At Zenkraft we like to experiment and find new ways to integrate our solutions with other cloud products. This time, we had fun researching and writing code around Twilio, a cloud communication platform.

One of the great features of Twilio is that makes it easy to add voice to your application. For this reason, we thought it’d be valuable if we could integrate this with our shipping apps for Salesforce, and allow users to get shipment status updates by calling a phone number.

We wanted to share with you an easy step-by-step process of how you could setup your own look up shipment status with Twilio voice. First of all, you’d know that you can allow customers to find shipment status from an inbound number from any object. For this particular example, we’ve integrated with a Case.

For our test, we exposed this URL “request URL”

Make sure that you put your VisualForce page we created earlier -called TwilioPage– into the Active Site Home Page section of this site:

The Twilio docs we used to build this demo are found here:

We also uploaded Sample Code on GitHub for you to test this feature. Sample code available here:

Continue reading »