Version: eXtendOrders 2.1.0 and above
Audience: Administrator, Developer

Overview

eXtendOrders allows you to customize line item generation through SuiteScript hooks. This means that you can modify what information sources to purchase orders, source additional body fields to line items, update line item values after the "Create Lines" button has been clicked in the Order Configurator to ensure updates source from body fields to your line items, or any other use cases that are not supported out of the box in eXtendOrders.

Support for Adding Additional Search Columns During Preconfigured OIC Search

If you have added additional fields on your Order Imprint Configuration (OIC) custom record, you will need to add those fields in the "ADDITIONAL_OIC_SEARCH_COLUMNS" variable in thesuite_orders_custom_hook_functions.js file.

Once added in this variable, it can be accessible from other hook functions to set values when preconfigured OICs are copied.

// Specify the OIC search columns while searching Pre-Config OIC Records. var ADDITIONAL_OIC_SEARCH_COLUMNS = [];

This functionality is useful when you want to pass additional information from preconfigured OICs to order OICs. This is done through a custom field on the OIC, which is then used on transaction records during line item generation. In this case, you can specify the field under the variable ADDITIONAL_OIC_SEARCH_COLUMNS. Then, you can set its value mapping from preconfig to OIC generation using the preconfigToOicHook function, as shown in the example below.
**
 *
 * @param {Object} args
 * @prop {Object} args.oicLineSublistWrapper
 * @prop {Object} args.lineItemSublistwrapper
 * @prop {Object} args.newRecord
 * @prop {Object} args.oicSearchRecord
 */
function preconfigToOicHook(args) {
 var newRecord = args.newRecord;
 var oicLineSublistWrapper = args.oicLineSublistWrapper;
 var lineItemSublistWrapper = args.lineItemSublistWrapper;
 var oicSearchRecord = args.oicSearchRecord;
 /* To set the body fields to OIC line here while creating the OIC line from pre-config items.
 Below line of code is the sample code to set the value in OIC lines.
 Please do not open the comment for below lines as this is sample code.
 oicLineSublistWrapper.select(args.line);
 oicLineSublistWrapper.setValue({fieldId: 'custrecord_extend_oic_v2vshipdate', value: lineItemSublistWrapper.getValue({fieldId: 'custcol_extend_v2vshipdate'})});
 */
 oicLineSublistWrapper.setValue({ fieldId: 'yourfield', value: oicSearchRecord.getValue({ name: '' }) });
}

Support for Copying or Transforming with the 'Copy Order/Transform Order' Buttons

getCopiedLineItemsHook

This function is utilized to retrieve data from the line items as a backup. It returns an object containing the backup fields.
/**
 * @param {Object} args
 * @prop  {Object} args.lineItemSublistWrapper
 * @prop  {Object} args.copiedRecord
 */
function getCopiedLineItemsHook(args) {
  var lineItemSublistWrapper = args.lineItemSublistWrapper;
  var copiedRecord = args.copiedRecord;
  var lineItemHookObject = {};

  lineItemHookObject['costestimate'] = lineItemSublistWrapper.getValue({ fieldId: 'costestimate' }) || 0;

  return lineItemHookObject;
}

setCopiedLineItemsHook

This function is used for setting the backup fields in the getCopiedLineItemsHook function.
/**
 * @param {Object} args
 * @prop  {Object} args.lineItemSublistWrapper
 * @prop  {Object} args.copiedRecord
 * @prop  {Object} args.lineItemHookObject
 */
function setCopiedLineItemsHook(args) {
    var lineItemSublistWrapper = args.lineItemSublistWrapper;
    var copiedRecord = args.copiedRecord;
    var lineItemHookObject = args.lineItemHookObject || {};
  
    log.debug({ title: 'setCopiedLineItemsHook lineItemHookObject', details: lineItemHookObject });
  
    if (lineItemHookObject['costestimate']) {
      lineItemSublistWrapper.setValue({ fieldId: 'costestimate', value: lineItemHookObject['costestimate'] });
    }
  }

beforeRecordSaveForCopyRecord

This function is used before saving the copied / transformed record.
/**
 * @param {Object} args
 * @prop  {Object} args.copiedRecord
 * @prop  {Array}  args.oicSearchResult
 */
function beforeRecordSaveForCopyRecord(args) {
    var copiedRecord = args.copiedRecord;
    var oicSearchResult = args.oicSearchResult;
  
    log.debug({ title: 'beforeRecordSaveForCopyRecord', details: 'beforeRecordSaveForCopyRecord hook initiated' });
  }