addBreakoutItem()

Note:

Additional items were previously called breakout items.

The addBreakoutItem() function (client-side) adds an additional item to the configuration by including it in the SOLE/ITEMS predefined answer, which represents the list of active additional items. For more information about additional items, see Including Additional Items Related to the Configurable Item.

If the associated action runs always or during the running phase, users will see the additional item listed under the corresponding section of the Audit menu. If the action runs on the submission phase, the additional item will be added as an item line to the transaction when users submit the configuration.

Note:

An additional item added by this function is only available during the current processing flow. To keep the additional item in SOLE/ITEMS, call addBreakoutItem() in the every processing flow. Each processing flow consists of the following steps: before-event actions run, building blocks are refreshed, after-event actions run. This processing flow repeats with every mouse click.

You can also use the function to create or update an item record. The item record will be added to the configuration as an additional item, and it will be created or updated when users submit the configuration. This item will be stored in your NetSuite account.

Syntax

Use this syntax for the addBreakoutItem() function:

            addBreakoutItem({
    itemid: string, // itemid OR item
    item: string | object, // itemid OR item
    price: number | string,
    qty: number | string,
    sequence: number | string,
    itemName: string,
    displayName: string,
    line: number | string, 
    group: string,     
    colmap: { 
        key1: value1,
        key2: value2, 
        key3: value3,
        // Additional key-value pairs
    }
}); 

          

Parameters

Note:

The required parameters are itemid or item. Using item slightly improves performance when submitting the additional item to the transaction.

The addBreakoutItem() function accepts a single object as a parameter. The object includes the following properties:

  • itemid - The item name or number.

    Note:

    The sku parameter was initially used to represent the item name or number. For new implementations, use itemid instead of sku.

  • item - The item internal ID (string) or an object. You can use the object to create or update item records that will be added to the configuration as an additional item, and then, to the transaction.

    To update an existing item, set update: true in the object. The default value is false, so you can omit this key if you want to create the item.

    Note:

    When creating an item record, make sure you include all required fields.

  • price - The price added to the Rate line item field on the transaction. If omitted, the value is sourced from the item record. If you use multiple currencies and price levels, the price will be automatically calculate based on the customer selected in the transaction. Quantity ranges will also be taken into account.

  • qty - The number of items to add. If the quantity isn't specified, the default value is 1.

  • sequence - The additional item sequence number. It determines the order in which the additional items will be added to the transaction. If omitted, additional items will be added to the transaction in the order in which the addBreakoutItem() function is called in the script. They will appear after any additional items added through additional item records.

    Note:

    If you use both the sequence and the line parameters, sequence will be disregarded.

  • line - The transaction line number. You can add the additional item to a specific line.

    When replacing a line item using this parameter, item-related fields will be updated with the new values from the new item. If you keep the value for the itemid or item parameters, you can update values for the price and custom line fields.

    Note:

    Make sure you overwrite existing lines only when required.

  • itemName - The content displayed in the Name column of the Additional Items section in the Audit menu.

  • displayName - The content displayed in the Item Name/Number column of the Additional Items section in the Audit menu.

  • group - The group for the additional item. To add the same item to the transaction multiple times and ensure correct pricing when discounts apply, assign each instance to a different group. Additional items without a group will be placed together.

  • colmap (object) - Key-value pairs to set additional line item fields on the transaction.

Examples

The following examples show how to use the addBreakoutItem() function.

Including an Additional Item in the Configuration

This example adds a DESKA1000-AB1 additional item to the configuration using the provided parameters.

              addBreakoutItem({
    itemid: 'DESKA1000-AB1',
    price: '400',
    qty: '1',
    sequence: '3',
    itemName: 'DESKA1000-AB1',
    displayName: 'Business Desk A1000-AB1',
    colmap: {
        custcol_item_origin: 'US'
    },
    group: 'Series A1000'
}); 

            

Creating an Additional Item

This piece of code creates an item record that will be used as an additional item in the configuration. The item will be created after users submit the configuration.

              addBreakoutItem({
    item: {
        itemid: 'DESKA1000-AB2',
        displayName: 'Business Desk A1000-AB2',
        taxschedule: '1',
        description: 'Business deluxe desk'
    },
    price: '400',
    qty: '1',
    colmap: {
        description: 'Office Desk',
        custcol_item_origin: 'US'
    }
}); 

            

Updating an Additional Item

This example updates an item record that will be used as an additional item in the configuration. The item will be updated after users submit the configuration.

              addBreakoutItem({
    item: {
        itemid: 'DESKA1000-AB1',
        displayName: 'Business Desk A1000-AB1 - Updated Version',
        taxschedule: '1',
        description: 'Business deluxe desk',
        update: true
    },
    price: '400',
    qty: '1',
    colmap: {
        description: 'Office Desk',
        custcol_item_origin: 'US'
    }
}); 

            

Related Topics

General Notices