Good morning, does anyone know how to set the inve...
# suitescript
a
Good morning, does anyone know how to set the inventory detail for a fulfillment created from a sales order transform? I'm getting the following error: 'TypeError: fulfillRecord.getCurrentSublistSubrecord is not a function " the code is :
let listIds = listIdbk.replace(/\[|\]|"/g, "").split(",");
log.audit("entro listIdbk", "1"); const pdfIds = []; listIds.forEach((orderId) => { try { log.audit("orderId", orderId); // Obtener los detalles de la orden de venta const salesOrder = record.load({ type: record.Type.SALES_ORDER, id: orderId, isDynamic: true }); log.audit("salesOrder", salesOrder); const lineCount = salesOrder.getLineCount({ sublistId: 'item' }); // Obtener las líneas de la orden de venta log.audit("lineCount", lineCount); var fulfillRecord = record.transform({ fromType: 'salesorder', fromId: orderId, toType: 'itemfulfillment' }); log.audit("fulfillRecord", fulfillRecord); for (let i = 0; i < lineCount; i++) { const itemId = salesOrder.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); const quantity = salesOrder.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); log.audit("linea", "84"); log.audit("itemId", itemId); log.audit("quantity", quantity); // Realizar una búsqueda de lotes disponibles para el artículo actual const lotNumbers = assignLotsByFEFO(quantity, itemId); log.audit("lotNumbers", lotNumbers); fulfillRecord.setSublistValue({ sublistId: 'item', fieldId: 'itemreceive', line: i, value: true }); log.audit("linea", "113"); fulfillRecord.setSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i, value: quantity }); log.audit("linea", "122"); var subrec = fulfillRecord.getCurrentSublistSubrecord({ sublistId: 'item', fieldId: 'inventorydetail' }); log.audit("sublistFieldMetadata", subrec); log.audit("linea", "127"); } var fulfillmentId = fulfillRecord.save(); log.audit('Fulfillment Created', 'Fulfillment ID: ' + fulfillmentId); } catch (error) { log.error({ title: "Error processing order", details: error }); }
a
Try
getSublistSubrecord
thanks 1
a
hi @alien4u it works for me thanks, but now i have another issue, when I set the Lot obtain the error "{"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value 47 for the following field: issueinventorynumber","id":"","stack":["Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js37113)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js11524)\n at /SuiteScripts/ACS CSTM REMISIONES MASIVAS/SS_asigna_masiva_lotes_remision.js15363\n at Array.forEach (native)\n at Object.onRequest (/SuiteScripts/ACS CSTM REMISIONES MASIVAS/SS_asigna_masiva_lotes_remision.js5329)"],"cause":{"type":"internal error","code":"INVALID_FLD_VALUE","details":"You have entered an Invalid Field Value 47 for the following field: issueinventorynumber","userEvent":null,"stackTrace":["Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js37113)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js11524)\n at /SuiteScripts/ACS CSTM REMISIONES MASIVAS/SS_asigna_masiva_lotes_remision.js15363\n at Array.forEach (native)\n at Object.onRequest (/SuiteScripts/ACS CSTM REMISIONES MASIVAS/SS_asigna_masiva_lotes_remision.js5329)"],"notifyOff":false},"notifyOff":false,"userFacing":true}" , this part of code is:,
var inventoryDetailRecord  = fulfillRecord.getSublistSubrecord({
sublistId: 'item', fieldId: 'inventorydetail', line: i, }); inventoryDetailRecord.setSublistValue({ sublistId: 'inventoryassignment', fieldId: 'issueinventorynumber', value: '47', line: 0 }); inventoryDetailRecord.setSublistValue({ sublistId: 'inventoryassignment', fieldId: 'quantity', value: 200, line: 0 });
a
Two different sublist sub-record behavior for that one, basically: • If you are consuming a lot/serial, like in a Fulfillment the field ID is different. • If you are receiving(= creating) a lot/serial, then the field id is
issueinventorynumber
a
yes, I'm supposed to assign an existing lot to complete the execution of the sales order with the fulfillment
a
Or the otherway around... some examples:
Copy code
const headerInventoryDetail = assemblyBuildRec.getSubrecord({fieldId: 'inventorydetail'});
headerInventoryDetail.setSublistValue({
                        sublistId: 'inventoryassignment',
                        fieldId: 'receiptinventorynumber',
                        value: serialNumber,
                        line: i
                    });
Copy code
oDetailRec.setSublistValue({
    sublistId: 'inventoryassignment',
    fieldId: 'issueinventorynumber',
    value: oDetail.SERIAL_ID,
    line: 0
});