Version: eXtendASI-DE 1.3.2.26
Audience: Administrator, Developer

Overview

eXtendASI allows you to create items with dynamic item types (such as Inventory Item, Non-Inventory Item for Resale, etc.) according to your needs.

The two methods below allow for dynamic item type selection during item constitution.

Configuration

1. Manual selection of the Item Type from the Item Search screen

On the eXtendASI Setup page, enable the "Select item type during constitution" preference to allow a dropdown field on the item search screen for item type selection.

Image Placeholder

After the preference has been enabled, an "ITEM TYPE" dropdown will be displayed on the eXtendASI Item Search page.
Image Placeholder

2. Dynamic Item Type selection based on Item Category from the Item Search screen

If you want to set the item type dynamically based on the category field, you will include a hook function named setItemType() in the suite_asi_transformers.js file.

An example is below where a secondary category is configured on the eXtendASI Setup page, and the item type will be set dynamically based on the selected secondary category value during item constitution.

For instance, the secondary category field might contain the following values:
i. Special Order
ii. Drop Ship
iii. Program


In the function below, we will set the item type as "Inventory Item" if the user selects a secondary category of "Special Order". If the user selects any other option, the item type for constitution will be considered as "Non-Inventory Item". This function will be added in the suite_asi_transformers.js file.
 /**
   * @param {Object} args
   * @prop  {String} args.itemType
   * @prop  {String} args.itemConstitutionType
   * @prop  {Boolean} args.isParentRecord
   * @prop  {String} args.yourCategory
   * @prop  {String} args.category1ListId
   * @prop  {String} args.yourCategory_2
   * @prop  {String} args.category2ListId
   * @prop  {String} args.sourceNativeRecord
   */
  function setItemType(args) {
    var yourCategory_2 = args.yourCategory_2;
    var itemType = args.itemType;
    var category2ListId = args.category2ListId;

    if (!yourCategory_2 || !category2ListId) {
      return itemType;
    }

    var category2SearchResults = search.create({
      type: category2ListId,
      filters: [
        ['isinactive', 'is', false],
        'AND',
        ['internalid', 'anyof', yourCategory_2],
      ],
      columns: [{ name: 'name'}]
    }).run().getRange({ start: 0, end: 1 }) || [];

    if (category2SearchResults.length !== 1) {
      return itemType;
    }

    var category2Name = category2SearchResults[0].getValue({ name: 'name' }) || '';
    if (category2Name && (category2Name.toLowerCase() === 'special order')) {
      return 'inventoryitem';
    } else if (category2Name && ((category2Name.toLowerCase() === 'drop ship') || (category2Name.toLowerCase() === 'program'))) {
      return 'noninventoryitem';
    } else {
      return itemType;
    }
  }

Note: If the user doesn't specify the secondary category in the example case above, then the item type manually selected in the "ITEM TYPE" dropdown field will be used. If the item type selection on the item search screen is not enabled, then the item type defined in the eXtendASI Setup page will be used.