background

Zenkraft Blog

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

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 »

Create a button to replicate the Custom Address Source “New Shipment Functionality”

Published on 26 April 2017 by in  

Today we will show you how to create a custom button on your object that does the same as the New Shipment button from your related list.

The most usual use case for this is if you want to create 2 one click shipment buttons from a standard or custom object. One for a standard outbound shipment, and the other for a return shipment.

For this demo we will use the standard Case object. The first thing we need to do is make sure our Custom Address Source related lists already added to the page. If you haven’t set up your custom address sources for one click shipping please look at the documentation found on our docs page here: https://docs.zenkraft.com/usps/one-click-shipments

Once you have your two related lists on the page like so:
 

Two Related Lists

Click on the first button and copy the resultant URL
 

Two related lists

You should get something like this:
https://zkusps.xxxx.visual.force.com/apex/Wizard?CF00NE0000003lPgf=00001026&CF00NE0000003lPgf_lkid=500E000000VCQyo&scontrolCaching=1&retURL=%2F500E000000VCQyo&sfdc.override=1

Paste this URL somewhere you can get to it later on, we will need it.

Next go to Setup > Customize > Cases > Buttons, Links, and Actions

Click the “New Button or Link” button.

Buttons, Links and Actions

Enter a Label and Name. Select “Detail Page Button”. Under the Behaviour select “Display in existing window without sidebar or header.” Set the Content Source to be “URL”.

Remember the link you copied and put somewhere safe? Lets copy that and paste it into the text area.

There are three changes we need to make to the URL. Lets split out the URL so its easier to read. Every time you see the “&” or “?” press enter.

We should end up with something similar to this:

https://zkusps.na39.visual.force.com/apex/Wizard

?CF00NE0000003lPgf=00001026
&CF00NE0000003lPgf_lkid=500E000000VCQyo
&scontrolCaching=1
&retURL=%2F500E000000VCQyo
&sfdc.override=1

This is the point you need to insert a merge field.
 

The first one to replace is the “Case Number” of the Case object. In this example 00001026 will be replaced with this merge field{!Case.CaseNumber}

And the next two replacements of 500E000000VCQyo are the salesforce case ids, which are replaced with {!Case.Id} as you can see here.

Click save and you are done for this part.
The next step is to add this newly created button onto your case object. To do that navigate to any Case and click on Edit Layout.

 

Click on Buttons, and find the button you created earlier “Create USPS Shipment”, and drag it down into the Custom Buttons section.

 

Then click save.
Test out the button that has now appeared.

 

Hopefully that has now worked for you, and you can do the same steps to create the Create a Return USPS Shipment button, that linked to the second Custom Address Source button.

As always we are here to help so contact us for any queries.

Continue reading »