Use Process Builder to Get Multi-Carrier Rates
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 rate request from an Quote object when creating a new quote is created.
Step 1. Set all required fields in your Custom Address Source
In your Custom Address Source you will need to have these items set as a minimum*:
Recipient Address Fields:
Street 1 Text Line Field
Postal Code Field
Payment Type Field: the value of this field can be set to SENDER, RECIPIENT, THIRD_PARTY
Preference Name Field: the value of this field can be set to the name of the preference (e.g. "ShipmatePreference-0000")
Ship Date* (only required for FedEx)
Ship Date Field : ensure this is a date field. If you want to use todays date, just add this value to the formula field - TODAY()
Service Type Field: such as FEDEX_2_DAY, FEDEX_GROUND, FIRST_OVERNIGHT. (FedEx Service Type Examples)
Package Type Field: such as FEDEX_BOX, FEDEX_ENVELOPE, YOUR_PACKAGING. (FedEx Package Type Examples)
Add Packages or use Boxing Algorithm
You must add at least one package row, if you're not using the boxing algorithm. Fields needed are Quantity, Weight, and Declared Value.
Or you can use our boxing algorithm and the selections below, for example. You select 'use child object' for the Quote object, so you can access the products listed in your 'Quote Line Items'.
This section defines which fields on your original object (in our case the Quote object), you would like the rate information that is returned to be populated to. Map the Shipping and Handling field to the Output Net Charge Field. When a new quote is generated, the the rate will populate in the Shipping and Handling field on the Quote object.
This section defines the field on your original object (in our case the Quote object), that you would like any error messages to be returned to. Simply create a text field with the maximum 255 character limit and map that into this field on the Custom Address Source:
Auto Create Shipment must be checked
Step 2. Process Builder Task
Navigate to Setup | Create | Workflow & Approvals | Process Builder | New (Salesforce Classic)
Navigate to Setup | Enter 'Process Builder' into the Quick Find Box | Click Process Builder | New (Salesforce Lightning)
Enter a Process Name, Description, and start the process when a record changes
Click Add Object | Choose Quote | Select ‘when a record is created or edited’
Click Add Criteria | Enter a Criteria Name | Select No criteria -- just execute the actions!
Click Add Action | Select Apex for Action Type | Enter an Action Name | Select the Get Rate (Multi-Carrier) Apex Class.
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 Quote ID.
Click Save and then Activate the process.
If you have missed a step and the rate isn’t created, you can view error messages under Setup | Jobs | Apex Jobs.
The error messages are extremely helpful in debugging.
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.