I am wanting to display lot numbers on item fulfilment and invoices. I don't have any scripting ability... sadly...
So I implemented this script and it works really well. https://jcurvesolutions1.zendesk.com/hc/en-us/articles/4711971574425-Remove-Bin-Number-from-item-inventorydetail-When-Printing-with-Advanced-PDF-Templates
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/record'],
function(record) {
function beforeSubmit(scriptContext) {
var rec = scriptContext.newRecord;
var lines = rec.getLineCount({sublistId:'item'});
var tempS = '';
for(var i=0;i<lines;i++){ // for each line
var subList = rec.getSublistSubrecord({
sublistId:'item',
fieldId:'inventorydetail',
line:i
});
if(subList.getValue('id')){ //if the line has inventory details
var sublistLines = subList.getLineCount({
sublistId:'inventoryassignment'
});
for(var j=0;j<sublistLines;j++){ //for each line of the inventory details
tempS+=subList.getSublistText({
sublistId:'inventoryassignment',
fieldId:'issueinventorynumber',
line:j
});
if(j<sublistLines-1) tempS+='\n';
}
rec.setSublistValue({
sublistId:'item',
fieldId:'custcol_tb_lot_no_via_js',
line:i,value:tempS
});
tempS='';
}
}
}
return {
beforeSubmit: beforeSubmit
};
});
However I have one issues with it. In our Netsuite account I have it set up so that Invoices display items that are on Backorder. However backorder items don't have "inventory detail" so when I try and edit or save the invoice I get the following error.
{"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Invalid number (must be positive)","stack":["anonymous(N/serverRecordService)","beforeSubmit(/SuiteScripts/DisplayLot# Packing Slip.js:16)"],"cause":{"type":"internal error","code":"USER_ERROR","details":"Invalid number (must be positive)","userEvent":"beforesubmit","stackTrace":["anonymous(N/serverRecordService)","beforeSubmit(/SuiteScripts/DisplayLot# Packing Slip.js:16)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}
It is due to one of the lines not having any inventory detail as it is on back order. so what I am asking is if some kind person could tell me what I need to change in the above script so that it ignores backorder items.
Thanks.