Version: eXtendPS-DE 1.3.4
Audience: Administrator, Developer

Use Case

  • Replace or remove specific characters present in an item name during item constitution with another character.

Overview

In some cases, you may want to replace certain characters in an item name during item constitution. This SuiteScript hook function allows for updating the item name according to business requirements at the time of item constitution.

Configuration

eXtendPS-DE supports a hook function called afterSaveItemIdUpdateHook(). This function updates the matrix item name template after the item is saved. To use this hook function, create the function in the suite_promo_transformers.js file.

In the example below, if any of the matrix options (especially color) contain a forward slash character /, it will be replaced with a period ..
/**
 * @param {Object} args
 * @property {String} args.itemNameTemplate
 */
function afterSaveItemIdUpdateHook(args) {
  let itemNameTemplate = args.itemNameTemplate;
  if (!itemNameTemplate) {
    return itemNameTemplate;
  }

  
  itemNameTemplate = itemNameTemplate.replace(/\//g, '.');
  return itemNameTemplate;
}

Note: You should use this approach only if the "MATRIX ITEM NAME TEMPLATE" defined on the eXtendPS-DE Setup page does not meet your needs.