FinancialForce Shipping Integration

FinancialForce SCM tool has a natural place for Zenkraft to integrate; the Shipping object. This object contains the shipping address information as well as fields available to be updated with tracking numbers, ship date, total weight, number of packages, and service type.

Aside from the standard directions for setting up the application LINK, the Zenkraft & FinancialForce integration has two parts. First, the address fields and contact details all need to be on the Shipping object. Second, after a shipment is created, fields need to be moved from the Zenkraft Shipment record, up to the FinancialForce Shipping record.

Step 1. Separate out address lines

Zenkraft shipping applications require that the address fields are separated out by Street Address, City, State, Zip, and Country code. These fields have to be on the Shipping record itself, so we will use a set of formula/text fields to accomplish this. From the setup menu > create > objects > shipping object > create new field. Here are some examples:

Shipping Street 

IF( ISBLANK( SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__c ) , 
SCMC__Sales_Order__r.SCMC__Customer_Account__r.ShippingStreet,
SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Mailing_Street__c)

Shipping Street 2

IF( ISBLANK( SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Mailing_Street_Additional_Information__c ) , '', 
SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Mailing_Street_Additional_Information__c ) +
IF( ISBLANK( SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Building_Information__c ) , '',
SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Building_Information__c)

Shipping City

IF( ISBLANK( SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__c ) , 
SCMC__Sales_Order__r.SCMC__Customer_Account__r.ShippingCity,  
SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Mailing_City__c)

Shipping State

IF( ISBLANK( SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__c ) , 
SCMC__Sales_Order__r.SCMC__Customer_Account__r.ShippingState,  
SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Mailing_State_Province__c)

Shipping Postal Code

IF( ISBLANK( SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__c ) , 
SCMC__Sales_Order__r.SCMC__Customer_Account__r.ShippingPostalCode,  
SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Mailing_Zip_Postal_Code__c)

Shipping Country

IF( ISBLANK( SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__c ) , 
SCMC__Sales_Order__r.SCMC__Customer_Account__r.ShippingCountry,
SCMC__Sales_Order__r.SCMC__Actual_Ship_To_Address__r.SCMC__Mailing_Country__c)

Step 2. Create Custom Address Source

You can now map your new FinancialForce address fields into the shipping wizard using a custom address source.

UPS Custom Address Source
FedEx Custom Address Source
USPS Custom Address Source
Multi-carrier Custom Address Source

Step 3. Add Trigger to Package Object

Use the trigger below to update the FinancialForce shipment object with the shipping fields shown below:

trigger UpdateTotalWeightAndPackageCount on zkups__UPSPackage__c (after insert) {
    // Lists to update
    List<zkups__UPSShipment__c> shipmentsToUpdateList = new List<zkups__UPSShipment__c>();
    List<SCMC__Shipping__c> ffShipmentsToUpdateList = new List<SCMC__Shipping__c>();

    // Get current shipments based on packages
    Set<Id> allShipmentsIdsSet = new Set<Id>();
    for (zkups__UPSPackage__c pkg : Trigger.new) {
        allShipmentsIdsSet.add(pkg.zkups__UPSShipment__c);
    }
    Map<Id, zkups__UPSShipment__c> shipmentsMap = new Map<Id, zkups__UPSShipment__c>([
            SELECT Total_weight_of_all_packages__c,
                   Total_number_of_packages__c,
                   Shipping__c
            FROM zkups__UPSShipment__c
            WHERE Id IN :allShipmentsIdsSet
            LIMIT 50000]);

    // Update shipments with new packages
    for (zkups__UPSPackage__c pkg : Trigger.new) {
        if (shipmentsMap.containsKey(pkg.zkups__UPSShipment__c)) {
            shipmentsMap.get(pkg.zkups__UPSShipment__c).zkups__ModKey__c = '<CONTACT ZENKRAFT SUPPORT FOR THIS KEY>';
            shipmentsMap.get(pkg.zkups__UPSShipment__c).Total_number_of_packages__c = shipmentsMap.get(pkg.zkups__UPSShipment__c).Total_number_of_packages__c + 1;
            shipmentsMap.get(pkg.zkups__UPSShipment__c).Total_weight_of_all_packages__c += pkg.zkups__Weight__c;

            shipmentsToUpdateList.add(shipmentsMap.get(pkg.zkups__UPSShipment__c));
        }
    }
    update shipmentsToUpdateList;

    // Get FF shipments
    Map<Id, zkups__UPSShipment__c> ffShipmentToUpsShipmentMap = new Map<Id, zkups__UPSShipment__c>();
    for (zkups__UPSShipment__c shipment : shipmentsToUpdateList) {
        ffShipmentToUpsShipmentMap.put(shipment.Shipping__c, shipment);
    }
    Map<Id, SCMC__Shipping__c> ffShipmentsMap = new Map<Id, SCMC__Shipping__c>([
            SELECT SCMC__Number_of_Boxes__c,
                   SCMC__Weight__c
            FROM SCMC__Shipping__c
            WHERE Id IN :ffShipmentToUpsShipmentMap.keySet()
            LIMIT 50000]);
   
    // Update FF shipments
    for (SCMC__Shipping__c ffShipment : ffShipmentsMap.values()) {
        ffShipment.SCMC__Number_of_Boxes__c = ffShipmentToUpsShipmentMap.get(ffShipment.Id).Total_number_of_packages__c;
        ffShipment.SCMC__Weight__c = ffShipmentToUpsShipmentMap.get(ffShipment.Id).Total_weight_of_all_packages__c;

        ffShipmentsToUpdateList.add(ffShipment);
    }
    update ffShipmentsToUpdateList;
}
Did this answer your question?