Applying Routing Rules

In the Administration App, you can configure routing conditions and routing rules, which specify optimal combinations of carrier, rating and billing detail (rules) which are applied to shipments that match predefined criteria (conditions). See Carriers - Routing Conditions and Rules for detail. To utilize the routing rules functionality, the Apps must be modified in Designer to make a Route request and apply the returned routing rules.

  1. From Product Admin, select the Design icon for the relevant App. This opens the App in Designer.
  2. Add a button, and in the Properties panel, set the Action to Xml Request.
  3. Click the cog icon, and select Pierbridge Route from the list.

  4. In the Action Options popup, click Edit Request Parameters, and map the fields to be passed in the request. The fields are compared against the criteria defined in your routing conditions. E.g. Weight, Destination, ShipTime.

  5. On response, any valid routing rules are returned. The following script is used to update the App and handle the returned results:
    // Handle routing rules response
    function getText(xml, nodePath) {
    var node = xml.selectSingleNode(nodePath);
    if (node) {
    return node.text;
    }
    return "";
    }
    
    pb.xmlHandler.complete(function (response) {
    var status = response.selectSingleNode("//Status/Code");
        
    if(status.text == "1") {
    var rateGroupID = getText(response, "//Routes/Route/RateGroupID");
    var carrierID = getText(response, "//Routes/Route/Carrier");
    var carrierServiceTypeID = getText(response, "//Routes/Route/ServiceType");
            
    if (rateGroupID) {
    control("CarrierService").setRateGroupByID(rateGroupID);
    } else if (carrierID && carrierServiceTypeID) {
    control("CarrierService").val(carrierID, carrierServiceTypeID, "");
    }
            
    $("#RateButton").click();
    }
    
    }, "Pierbridge Route");
    
    pb.RuntimeObservable.subscribe("pb.snippets.contentManager.packageChanged", function(activePage) {
    $("#packageCount").val(__ContentManager.count);
    });

    The script applies the routing rule detail, such as rateshop detail or carrier, and automatically performs a rate or rateshop.

Article last edited 17 December 2018