background

Zenkraft Blog

Run your Logistics and Post-Purchase Experience on the Salesforce Platform.

Bulk Cancel UPS shipments

Published on 18 July 2017 by in  

A quick code snippet for you today, if you want to cancel all UPS shipments that have not been picked up.

Here is the code to run in Developer Console:

Line 4 determines the shipments we want to set as cancelled. For this snippet we have decided to cancel all shipments older than UPS-Shipment-0000001000.

Line 7 then uses our startMassShipmentCancelBatch process that goes through all the shipments and cancels them.

Please contact us if you have any questions and we will be glad to help.

Continue reading »

Using Process Builder to Add FedEx Tracking Number to your Contact Object

Published on 11 July 2017 by in  

Today's blog post will show you how add the FedEx Tracking Number onto the Contact object after you have created a shipment.

Firstly make sure you have the text field available on your contact object:

 

Next let’s create a Process Builder task to retrieve the tracking number once the shipment has been created.

To access the process builder page, go to Setup > Create > Workflow & Approvals > Process Builder

Click on “New” and give it a name. We want to start this process when “A record changes” , so select that from the dropdown. This is what you should see:

You are now presented with this blank process builder screen.

Click on the “Add Object” button and select the “FedEx Shipment” object. We need to start the process only when a record is created.

 

The next step is to “Add Criteria”, and we want to ensure that there is a relationship to the contact object. We do this by filling in these fields here.

Here is the closer look at the “Field” value we have chosen

 

Next we click on “Set Schedule” and set the time for actions to execute at “0 Days After CreatedDate”

We do this as it creates a small delay after the shipment has been created, which ensures the shipment creation process is not blocked.

Next we need to select which records to update. Make sure you select “Recipient Contact”, and not “Recipient Contact >” as there is a big difference.

 

Next set the field value you want to update on the Contact object, which in our case is “FedEx Tracking Number”.

The Value field we are using is the Master Tracking Number as you can see here.

 

That’s it, lets activate it and do a test shipment from the contact object, and you should then see the tracking number appear like so:

If you have any issues then please contact us and we would be glad to help.

Continue reading »

Using Process Builder to send a custom email after shipment creation

Published on 04 July 2017 by in  

Here is a quick guide to show you how you can send an email to the recipient’s email address to let them know they shipment has been created and is being sent today, by using the integrated SalesForce Process Builder.

First you need to set up a new Process Builder task. Go into Setup > Process Builder and click on the New button in the top right hand side of the page, and fill in the details and click Save.

 

Click on “Add Object” and then search for “UPS Shipment object”, then Click “Save”

Next is adding the criteria requirement. We only want to run this task if there is an email address in the recipient field on the shipment object. So let’s set that up by first filling in the “Criteria Name”, and then clicking on the field and selecting recipient email.

We want to make sure that the email address at least has an @ sign in it, so we create the criteria as follows:

Next we will setup a Scheduled Action, to run 0 days after Created Date. We do this because we need this process builder task to run AFTER the shipment has been created. This ensures nothing blocks the shipment creation process. By setting the scheduled action to run after 0 days after shipment creation essentially means this process only runs a few seconds after the shipment creation.

You can see how this section should now look.

Click Save and let’s create the Action associated with this schedule.

We are going to create a new email alert and then the new template, but if you already have one ready to go, then just add it to the Email Alert box.

We will show you the steps needed in case you haven’t got them ready yet.

Click on “Create one”.

This takes you to the new Email Alert screen. Make sure you give this email alert a description, select UPS Shipment from the dropdown. You will then be able to find the “Email Field: Recipient Email and move it into the selected Recipients box.

The last thing we are missing is the Email template. So to do this we need to open a new tab and go to Setup > Communication Templates > Email Templates. Click the “New template” button to start creating your template email.

To keep things simple for this tutorial we will just create a text based email.

Give your email template a name, and add a subject line and email body.

To merge any fields into the subject or body of the email, select the first dropdown on the page under the “Available Merge Fields” heading, and select “UPS Shipment Fields” and the field you want to merge. You will then be able to copy and paste the variable that starts with {! and ends with }.

Once you have set up this email template Save it and go back to your Email Alert screen and add the newly created template as you can see here.

The final step is to add this email alert to your Process Builder task which you can see here:

Click save and make sure to Activate this Process Builder Task.

It’s always good to do a quick test to confirm its all working as expected.

Contact us if you have any queries.

Continue reading »

UPS Address validation on an Account

Published on 23 May 2017 by in  

Today's blog post will show the code you need to validate an Account address via the UPS Address Validation call you can find in the UPS Shipmate app.

Firstly we will look at the Controller code, and we will explain how it works below:

Lines 7-12: This is where you specify the name of the Account object that you want to validate the address for.

Lines 14-27: We need to get the details of our UPS Shipmate preference and store it into the shipmatePref variable.

Line 29: We create a new zkups_UPSShipment__c object that we will then use to run the validation method against.

Lines 30-34: We add the Account address details to the UPS Shipment object we created in line 29.

Line 36: We create the ValidateAddressResult which is populated by the zkups.ShipmentInterface.validateAddress method. The validateAddress method is the point at which we make the API call out to UPS.

Line 37 – 39: We check if the UPS web service has returned any results, and if so we add it to the validationAddressesList list.

Here is the Visualforce page code that you could link to from the account page that will show you the results of the UPS Address validation results.

Any questions, please do not hesitate to contact us!

Continue reading »