Version: eXtendASI-DE 1.3.2.21
Audience: Administrator, Developer

Overview

Due to the more complex mapping involved, Item Weight and Weight Unit mappings are not directly accessible from the eXtendASI Setup page as other configurations are.

To include the item weight and weight unit on constituted items, an additional functional mapping is required to be added in the suite_asi_transformers.js file.

Configuration

1. Search for the suite_asi_transformers.js file in NetSuite Global Search and edit the file.

2. Add a function named setItemWeightAndUnit(args) to the suite_asi_transformers.js file. A sample function is below.
  /**
   * @desc For setting the weight and weight unit
   * @param {Object} args
   * @prop  {Object} args.itemRecord
   * @prop  {Object} args.product
   */
  function setItemWeightAndUnit(args) {
    var itemRecord = args.itemRecord;
    var product = args.product;

    var weightPerPackage = _.get(product, 'Shipping.WeightPerPackage') || '';
    var weightUnit = _.get(product, 'Shipping.WeightUnit') || '';
    var itemsPerPackage = _.get(product, 'Shipping.ItemsPerPackage') || '';

    if (weightPerPackage && itemsPerPackage) {
      weightPerPackage = parseFloat(weightPerPackage);
      itemsPerPackage = parseFloat(itemsPerPackage);
      var weightPerItem = weightPerPackage / itemsPerPackage;
      weightPerItem = weightPerItem.toFixed(2);
      itemRecord.setValue({ fieldId: 'weight', value: weightPerItem });

      if (weightUnit && WEIGHTUOM_MAP[weightUnit]) {
        itemRecord.setText({ fieldId: 'weightunit', text: WEIGHTUOM_MAP[weightUnit] });
      }
    } else {
      var weightValues = _.get(product, 'Shipping.Weight.Values') || [];
      if (weightValues.length === 1 && _.isString(weightValues[0])) {
        itemRecord.setValue({ fieldId: 'weight', value: weightValues[0] }); //Define the fieldid where you want to set the weight
      }
    }
  }


3. Provide a mapping between the units received in the ASI item response and your NetSuite weight units as shown below:
var WEIGHTUOM_MAP = {
    //Add UOM mapping here e.g. {'ASI Weight Unit': 'NS UOM Text'}
    'Pounds': 'lb'
  };

Additional Notes

  1. This function will set the weight and its unit in NetSuite's "weight" and "weightunit" fields. If you want to store these values in different fields, you can do so by replacing these fields ids with your custom field ids in the code above.
  2. If the Shipping.WeightPerPackage and Shipping.ItemsPerPackage are both available from ASI, the function sets the weight to the WeightPerPackage field. The weight unit is set based on the WEIGHTUOM map above.
  3. If #2 is not applicable, then the function looks for Shipping.Weight.Values and sets the weight value to the user-specified field. In this case, the weight unit does not get set.