Hello All, I'm getting support to redirect me to A...
# suitescript
r
Hello All, I'm getting support to redirect me to ACS regarding adding serialized inventory
issueinventorynumber
for 25000+ items. I've attempted to insert an array of inventorynumbers and internalids without any luck. Could this be because of a type issue, string for inventorynumber and number for internalid? The problem, adding 25000 items 1by1 takes over 3600 seconds (20599 is about that time). We're filling a Transfer Order with this quantity.
b
its unlikely types are an issue, whatever you are doing is slow
in this case overloading the inventory assignment with more rows than it can handle in a performant matter
it will be especially slow if this is done in dynamic mode
r
Hmm, Here's the existing code
Copy code
idLineCount = 0; // For IF, this is true. IR it can be whatever the IF count is up to 10,000
    lineItem.serialIds?.forEach((serial, serialIndex) => {
      if (0 < idLineCount) {
        // Attempted workaround for Case # 5737571 DIGBIZ-1155
        inventorySubrecord.selectNewLine({
          sublistId: 'inventoryassignment'
        });
      } else {
        // Add based on index offset by what's already there, selectNewLine doesn't work if there's nothing there
        inventorySubrecord.selectLine({
          sublistId: 'inventoryassignment',
          line: idLineCount + serialIndex
        });
      }

      inventorySubrecord.setCurrentSublistText({
        sublistId: 'inventoryassignment',
        fieldId: record.Type.ITEM_RECEIPT == sourceRecordType ? 'receiptinventorynumber' : 'issueinventorynumber',
        text: serial,
        fireSlavingSync: false,
        forceSyncSourcing: true
      });

      inventorySubrecord.commitLine({ sublistId: 'inventoryassignment' });
    });
I've tried to change
serial
to an array with a splice of ~100, but I get an issue when I try the inventorynumber of the device. I suppose I can test ..sublistValue() with the internal ID's, but I assume I'll get the same error. I'll take a look at the dynamic mode too.
Without dynamic mode, I need to change the selectLine code
Here was the way I was doing the splice, that fell over
Copy code
idLineCount = 0; // True for IF, IR can be IF Qty up to 10000
    const spliceSize = 100;
    const originalSerialLength = serialsToSet?.length;

    for (let i = 0; i < serialsToSet?.length; i++) {
      let actualSpliceSize = spliceSize;
      // Check if less than splice size
      if (serialsToSet.length < spliceSize) {
        actualSpliceSize = serialsToSet.length;
      }

      log.debug({
        title: `${sourceRecordType} Inventory Detail`,
        details: `Inserting chunck ${actualSpliceSize} for total ${i * actualSpliceSize} out of ${originalSerialLength}`
      });

      const serialsToAdd = serialsToSet.splice(0, actualSpliceSize);

      if (0 < idLineCount) {
        // Attempted workaround for Case # 5737571
        inventorySubrecord.selectNewLine({
          sublistId: 'inventoryassignment'
        });
      } else {
        // Add based on index offset by what's already there, selectNewLine doesn't work if there's nothing there
        inventorySubrecord.selectLine({
          sublistId: 'inventoryassignment',
          line: idLineCount + (i * actualSpliceSize)
        });
      }

      // Bulk add with array of values
      inventorySubrecord.setCurrentSublistText({
        sublistId: 'inventoryassignment',
        fieldId: record.Type.ITEM_RECEIPT == sourceRecordType ? 'receiptinventorynumber' : 'issueinventorynumber',
        text: serialsToAdd,
        fireSlavingSync: false,
        forceSyncSourcing: true
      });

      inventorySubrecord.commitLine({ sublistId: 'inventoryassignment' });
    }
b
oh its worse, you are setting inventory numbers by their text
netsuite will need to do a lookup for each one that you do to get its internal id
r
Good news, I have an intermediate record that has the internalIds
b
and it will do it one by one for every line that you add since this is dynamic mode
r
I'll need to switch to SetSublistValue, unless it's an item receipt
b
im not really sure why dynamic mode would be requires on the item receipt
r
Item Receipt is not the current limitation and I am using the
internalid
for the item fulfillment. Is the suggestion here then to use setSublistValue instead of setSublistText for the itemfulfillment?
b
yes, quit using text, and stop using dynamic mode