Our invocable method allows you to create a shipment from any object that you have set up a Custom Address Source for using Process Builder. If you haven't set up a Custom Address Source then please follow this guide that explains how to do so.

In this example we will create a shipment from the Opportunity object when the Stage field gets set to "Closed Won".

Step 1. Set all required fields

In your Custom Address Source you will need to have these items set as a minimum:

Recipient Address Fields:
Name Field
Street 1 Text Line Field
City Field
State Field
Postal Code Field
Country Field
Phone Field

Billing Field
Payment Type Field: the value of this field can be set to SENDER, RECIPIENT, THIRD_PARTY

Shipmate Preference
Shipmate Preference Field: the value of this field can be set to the name of the preference (e.g. "ShipmatePreference-0000")

Ship Date
Ship Date Field: ensure this is a date field. If you want to use today's date, just add this value to the formula field - TODAY()

Service Types
Service Type Field: consult our carrier specific documentation for service types

Package Types
Package Type Field: consult our carrier specific documentation for package types

Packages
You must add at least one package row. Fields needed are Quantity, Weight, and Declared Value.

Shipment Auto-create
Auto Create Shipment must be checked

Step 2: Create Process Builder Task

Create a Process Builder Process by going to Setup > Create > Workflow & Approvals > Process Builder and click the New button.

Give the process a name, description, and choose to start the process when "A record changes".

Next choose the object you are starting the process from. Remember in this guide, we are using the Opportunity object, and we will be running the shipment creation once the Stage field is set to "Closed Won".

Make sure you set the "Start the process" to be "when a record is created or edited". Click Save, and then select "Add Criteria".

Fill in your requirements for when the shipment process should start. In this guide we are going to check that the Stage field is set to "Closed Won".

Click Save.

Next add an immediate Action. The Action Type will be "Apex", and the Apex Class will be "Create Shipment (Multi Carrier)".

You will then be able to set the Apex variables.

For the customAddressId please set it to the Custom Address Source ID that you are running this process from. To get this ID, navigate to your Custom Address Source and copy the last part of the URL. If you are in Lightning just use the first 15 characters of this objectId. 

For the recordId please set the Type as Field Reference, and the value to be the Object ID. In our case it will end up being the Opportunity ID.

Once set up correctly, it should look like this: 

Click Save, and don't forget to Activate this Process Builder. 

That is all set, you will now be able to have shipments created via process builder. 

Once you have activated the process builder, go to an Opportunity, change its Stage to "Closed Won" and a shipment will be auto-created.

Troubleshooting

If you have missed a step and the shipment isn't created, you can view error messages under Setup > Jobs > Apex Jobs.

The error messages are extremely helpful in debugging. For example, you can see that in the below screenshot the Shipmate Preference was missing and at another time the Shipping Date was missing and finally the Bill To was missing.

The top most job shows that the process completed successfully.

Please contact us using the icon to the bottom right of this screen if you have any queries, and we will be glad to help.

Did this answer your question?