Version: eXtendAlphaBroder 1.0.2.21 and above
Audience: Administrator, User, Developer

Problem

Upon item constitution, you may encounter a "Multiple Parent Items Found" error. This error occurs when there are multiple parent matrix items in your account that have the same name or share the same alphabroder style name.

Solution

If you've confirmed that you don't have two parent items with the same name or the same alphabroder style name, and you're still encountering the error, you'll need to add an afterItemMatchingSearch() function. This function, as shown below, should be added to the suite_alpha_transformers.js file. It allows you to write NetSuite account-specific logic to filter out duplicate parent items from the default item match criteria.

/**
    * @param args
    * @prop {Boolean} args.isParentRecord
    * @prop {Array} args.nsItemRecordSearchResults
    * @prop {Object} args.sourceNativeRecord
    */
function afterItemMatchingSearch(args) {
    var sourceNativeRecord = args.sourceNativeRecord;
    var nsItemRecordSearchResults = args.nsItemRecordSearchResults;
    var requestedParentSku = sourceNativeRecord.style ? ('alb-' + sourceNativeRecord.style) : sourceNativeRecord.style;
    var isParentRecord = args.isParentRecord;
    var invalidItemSearchIndexes = [];

    if (isParentRecord) {
    nsItemRecordSearchResults.forEach(function (itemSearchResult, i) {
        var parentSku = itemSearchResult.getValue({ name: 'itemid' });
        if ((requestedParentSku === parentSku) || (sourceNativeRecord.style == parentSku)) {
        return;
        }
        invalidItemSearchIndexes.push(i);
    });
    invalidItemSearchIndexes.sort(function (a, b) { return b - a; } );
    invalidItemSearchIndexes.forEach(function (index) {
        nsItemRecordSearchResults.splice(index, 1);
    })
    log.audit({
        title: 'afterItemMatchingSearch returning check',
        details: {
        requestedParentSku: requestedParentSku,
        nsItemRecordSearchResults: nsItemRecordSearchResults,
        invalidItemSearchIndexes: invalidItemSearchIndexes
        }
    });

    }
}