The standard process that Infoplus uses to create parcel labels with our Manifesting partners relies on data from your Orders, Cartons, Products, Parcel Accounts, and more, combined with a core set of business rules that Infoplus understands.  


Due to the ever-changing nature of writing and maintaining scripts, Infoplus does not provide support in this area. We recommend someone in your IT Department handles scripting requests internally so that you keep all control over the process.


However, there are times when you may need to customize the data or business rules that you use to create shipments and parcel labels. For example, some orders may need dry ice added to them based on the products or order's ship-to address. Or you might have a business rule that says based on the carrier you want to increase or decrease the total weight of a Carton in certain circumstances.  Infoplus allows you to customize Manifest calls in cases like these, using Manifest Scripts.  Here's how they work.


Create a Manifest Script

To create a Manifest Script, simply navigate to the Script table in Infoplus.  Create a new Script, and choose the Script Type of Manifest.  


For the code in a Manifest script, there is a single function that you must define which allows you to customize the data passed to EasyPost when creating shipments and getting rates:

  • customizeEasypostPreRatesCall - This function allows you to customize the data being sent in the Create Shipment call to Easypost.  This script will have access to a global variable called shipmentMapForRate, which is a java Map object (i.e., it has get and putmethods).  You can modify the data in this map, according to Easypost's shipment api documentation, to change the rates & labels that Infoplus will receive.

When you create a new Manifest Script, Infoplus will pre-populate the Code field with a comment that describes in more detail the variables and functions available in a Manifest Script.  


Assigning a Manifest Script to an Order

To use a Manifest Script, it must be applied at the Order level. You can select it when Creating or Editing an Order in Infoplus, with the Manifest Script field on the order table:


You can also automatically set a Manifest Script on an Order using a Trigger and your User Filter. Add the action of Change Manifest Script and the Manifest Script you would like set on the orders. Read more about Triggers here



Testing Manifest Scripts

To test a Manifest Script you must create Parcel Labels for a valid Infoplus Order. This can be done in either your test or live site as long as you have Parcel Accounts setup. 


We recommend running a Fulfillment Process against a test order, with the Create Labels field set to True.  You can edit your script, and use the Run Pick Pack Ship action on your Fulfillment Process to quickly void existing labels for your test orders, and re-create the labels again as needed, providing a quick turn-around cycle for testing changes to the script.

Error Handling

If your Manifest Script produces an error, Infoplus will not be able to complete the process of creating parcel labels.  This error will be presented in Infoplus at whatever point a user is trying to create parcel labels (such as when running Fulfillment / Pick Pack and Ship, or at the Ship Station, or from the Create Parcel Labels process).  

Example Manifest Scripts

Adding Dry Ice

In this example, this script is applied to Orders that require dry ice to be added to the label.

////////////////////////////////////////////////////////////////////////////
// customizeEasypostPreRatesCall
//
////////////////////////////////////////////////////////////////////////////
function customizeEasypostPreRatesCall()
{
   utils.log("Starting customizeEasypostPreRatesCall");
   utils.log("Running for Order: " + orderNo);

   utils.log("Shipment options before customization: " + shipmentMapForRate.get('options'));

   //////////////////////////////////////////////////
   // Add Dry Ice to the options for this shipment //
   // Also add our standard weight of 160oz        //
   //////////////////////////////////////////////////
   shipmentMapForRate.get('options').put('dry_ice', '1');
   shipmentMapForRate.get('options').put('dry_ice_weight', '160');

}

Setting Third Party Account For International Duties and Tax Charges

By default, an international order with a third party parcel account assigned to it will have the charges for duties and taxes assigned to the original parcel account, rather than the third party.  This can be changed using a Manifest Script by specifying what account should be responsible for these charges.  This is currently only possible with FedEx and UPS accounts and how this is specified in the data sent to these carriers differs between the two.  Please see the example below which shows how these changes can be implemented.

////////////////////////////////////////////////////////////////////////////
// customizeEasypostPreRatesCall
//
////////////////////////////////////////////////////////////////////////////
function customizeEasypostPreRatesCall()
{
   utils.log("Starting customizeEasypostPreRatesCall for Order: " + orderNo);
   utils.log("Shipment options before customization: " + shipmentMapForRate.get('options'));

   /////////////////////////////////////////////////////////////
   // look up the order to get its third party parcel account //
   /////////////////////////////////////////////////////////////
   var order = infoplusApi.getById("order", orderNo);
   if(order == null)
   {
      throw("Unable to find an order for orderNo [" + orderNo + "].");
   }

   if(! order.thirdPartyParcelAccountId)
   {
      throw ("This order does not have a third party parcel account associated with it.");
   }

   var thirdPartyParcelAccount = infoplusApi.getById("thirdPartyParcelAccount", order.thirdPartyParcelAccountId);
   if(thirdPartyParcelAccount == null)
   {
      throw ("Unable to find a third party parcel account with id [" + order.thirdPartyParcelAccount + "].");
   }

   utils.log("Found carrier: " + thirdPartyParcelAccount.carrier);
   if(thirdPartyParcelAccount.carrier.equals("FedEx"))
   {
      ////////////////////////////////
      // fedex account no goes here //
      ////////////////////////////////
      shipmentMapForRate.get('options').put('duty_payment_account', thirdPartyParcelAccount.accountNo);
   }
   else if(thirdPartyParcelAccount.carrier.equals("UPS"))
   {
      ////////////////////////////////////////////////////
      // setup the directive for 3rd party duties/taxes //
      ////////////////////////////////////////////////////
      var dutiesMap = {};
      dutiesMap["type"] =  "THIRD_PARTY";
      dutiesMap["account"] =  thirdPartyParcelAccount.accountNo;
      dutiesMap["postal_code"] = thirdPartyParcelAccount.zipCode;
      dutiesMap["country"] =  thirdPartyParcelAccount.countryCode;

      /////////////////////////////
      // update the shipment map //
      /////////////////////////////
      shipmentMapForRate.get('options').put('duty_payment', dutiesMap);
   }
   else
   {
      throw ("An unsupported carrier for third party duty billing was found.");
   }

   //////////////////////
   // audit the update //
   //////////////////////
   utils.log("Adding audit...");
   infoplusApi.addAudit("order", order.orderNo, "Updated the duties payment account to be third party when sending data to carrier: thirdPartyParcelAccountNo=[" + thirdPartyParcelAccount.accountNo + "].");

   ////////////////////
   // log the change //
   ////////////////////
   utils.log("Shipment options after customization: " + shipmentMapForRate.get('options'));
}