Use the Shipment Table to Add a Surcharge

Use a custom field via an API call for the Shipment table to add a surcharge for customers.

You can use custom fields in Infoplus to customize your API calls. To learn more about custom fields in the API, see this article. 

Use Case:

Use the Shipment table to add a surcharge for your customers with a Custom Field. You can use this field to pull into a user report to run custom billing and manage the data from the Shipment table. 

Note: Right now, when you are trying to update the Shipment table using the API, you need to use parcelShipment, not just shipment.

Pro Tip: Custom Fields act differently than regular fields in the API. To update a custom field, you need to use infoplusApi.updateCustomFields to solidify your data in the field.


Solution
:

  1. Create a Custom Field for the Shipment table.
    For a more detailed explanation of how to create a custom field in Infoplus, take a look at these step-by-step instructions
    1. In this case, we used totalShippingCost


2.   Create a Script for Record = Shipment
utils.log("Current Total Shipping Cost: " + shipment.customFields.get("totalShippingCost"));

var totalShippingCost = (shipment.chargedFreightAmount * 1.0);

shipment.customFields.put("totalShippingCost", (shipment.chargedFreightAmount * 1.0) + (shipment.chargedFreightAmount * 0.1));

utils.log("New Charge: " + totalShippingCost);

shipment.customFields.put("totalShippingCost", totalShippingCost);

infoplusApi.updateCustomFields("parcelShipment", shipment);

utils.log("Updated Field: " + shipment.customFields.get("totalShippingCost"));


3.   Test the script

4.    Verify that the field did update