Well, made some good progress on inventory detail,...
# suitescript
r
Well, made some good progress on inventory detail, but ran into an out-of-memory issue assigning 4000 items, ran out of memory around 500. Next attempt is to see if I could use the express entry box instead of the line-by-line entry. Off to hunt the mechanism for getting to that entry box.
I was hoping I could get past the entry of the inventory detail and do this within the beforeSubmit, but I get a pop-up indicating line one of inventory detail must be set.
b
what does your code look like
r
I'm looping through the 4000 serial numbers on the issueinventorynumber. I'm ok with up to ~500, after that the browser runs out of memory. The snippet running the assignment
Copy code
// Set the serial numbers for each line in the iventory detail
      lineItem.serialIds.forEach((serial, idx) => {
        const desiredIndex = existingSerialCount + idx;
        if (isClient) {
          // eslint-disable-next-line no-console
          console.log('Serial Index: ' + desiredIndex + ' Serial: ' + serial);
        }
        else {
          log.debug({
            title: 'Serialized Inventory',
            details: 'Serial Index: ' + desiredIndex + ' Serial: ' + serial
          });
        }

        try {
          if (!isClient || 0 == desiredIndex) {
            sourceRecord.selectLine({
              sublistId: 'inventoryassignment',
              line: desiredIndex
            });
          }

          if (record.Type.ITEM_RECEIPT == sourceType) {
            sourceRecord.setCurrentSublistText({
              sublistId: 'inventoryassignment',
              fieldId: 'receiptinventorynumber',
              text: serial.toString(),
              forceSyncSourcing: isClient
            });
          }
          else {
            sourceRecord.setCurrentSublistText({
              sublistId: 'inventoryassignment',
              fieldId: 'issueinventorynumber',
              text: serial.toString(),
              forceSyncSourcing: isClient
            });
          }

          sourceRecord.commitLine({ sublistId: 'inventoryassignment' });

          response.detailsSet = true;
        } catch (e) {
          response.errors.push(serial + ' ' + desiredIndex + ' ' + e.name + ': ' + e.message);
        }
      });
}
b
i dont see anything other than the use of setCurrentSublistText instead of setCurrentSublistValue that would cause memory errors
although you wouldnt normally want to add 4000 sublist rows in the ui
even if it worked, it could take hours
r
Agreed, but I cannot save the IF record from the sales order without the serial numbers. i.e. my unwrapping script to get the serial numbers works off of a different field. Is my only option to go back to modifying the SO to put the serial numbers in via suitelet and "reloading" the item fulfillment record to pick up the fields?
Also, using sublistText allows me to skip a saved search to retrieve the internalId for the matching serial number. I think I'd run into the memory problem regardless.
b
just because your code doesnt get the internal ids doesnt mean netsuite's code isnt
not particularly sure why you are doing this in client script either, the ui is pretty unusable past 100 sublist rows
a
I think you need to fire Map reduce or schedule script that runs after submitting. so in the background lines will be added line by line https://stackoverflow.com/questions/45553419/suitescript-2-0-userevent-script-to-call-map-reduce
r
@ahmed saeed moawoad elmasry I'd love to do this, but I cannot save the item fulfillment without having the line quantity match the inventory detail quantity. It does not get to a beforeSubmit event as there is a UI dialog that prevents the execution.
@battk I was doing this client side to get a more natural flow, but it appears I have to go back to doing this on the sales order and refreshing the item fulfillment.
b
that will probably work fine as long as you dont need to support kit items
but in general, you create the item fulfillment serverside
r
Then just load the created IF record like the Save button does today. Sounds like using a custom button instead of the NS Save would allow me to bypass the blocking messages.
In exploring the idea of creating the IF server side, will the FedEx integration be automatic or that needs to have an execution step as well?
b
depends on what you mean by fedex integration
r
Native FedEx shipping label creation/tracking number based on packages. i.e. clicking the "calculate shipping" and the label creation on save.
b
you should get the realtime rates if you setup the packages and related fields
you will have to generate the label separately
r
OK, back on the approach of making an Item Fulfillment record from a sales order record.transform(). I'm having issues setting 'itemreceive' to true, the 'quantity' and others. I also was going to try to save the item fulfillment without the Inventory Detail, but that cannot be bypassed. Using the following (fromId and inventorylocation values are correct). The save here gives the error "Please configure the inventory detail in line 1 of the item list."
Copy code
{
record = require('N/record');
 newIfRecord = record.transform({
    fromType: record.Type.SALES_ORDER,
    fromId: 93774,
    toType: record.Type.ITEM_FULFILLMENT,
    isDynamic: true,
    defaultValues: { inventorylocation: 222 }
  });
  
  //save the newly created itemreceive
   itemFulfillmentId = newIfRecord.save({
    enableSourcing: true, //optional, default is false
    ignoreMandatoryFields: true  //optional, default is false
  });

  console.log(' Item Fulfillment ID: ' + itemFulfillmentId);
}
Additionally, I get "field.getSublistName is not a function" When doing the following on the same newIfRecord (before the save)
Copy code
newIfRecord.selectLine({
      sublistId: 'item',
      line: 0
    });      

    newIfRecord.setCurrentSublistValue({
      sublistId: 'item',
      fieldId: 'quantity',
      value: 100
    });
b
support case with netsuite for that particular issue
but current workaround is to make the item fulfillment in a server script instead
r
ok thanks, I'll submit a support case.
Good news, you're right it works in the server. Also, support is still investigating the client script issue.