Hi Everyone, I am trying to transform sales order ...
# suitescript
t
Hi Everyone, I am trying to transform sales order to item fulfillment using suitescript. While saving the record I am getting this error: Cannot read properties of undefined (reading 'getRecordManager'). Can anyone please help me out with this?
b
what does the code look like
t
for (var i = 0; i < line; i++) { var fetchedItemId = transformObj.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); for (var j = 0; j < itemFulfillLineArr.length; j++) { var fulfillItemId = itemFulfillLineArr[j].itemId; var parentType = itemFulfillLineArr[j].isparent; var commitQty = itemFulfillLineArr[j].qtyCommit; if (fetchedItemId == fulfillItemId && parentType == "parentKit") { console.log("Enter Into Parent Kit"); transformObj.setSublistValue({ sublistId: 'item', fieldId: 'fulfill', line: j, value: true }); console.log("fulfill True"); transformObj.setSublistValue({ sublistId: 'item', fieldId: 'location', line: j, value: '2' }); console.log("location set"); transformObj.setSublistValue({ sublistId: 'item', fieldId: 'quantity', line: j, value: commitQty }); console.log("Quantity set"); } if (fetchedItemId == fulfillItemId && parentType == "childofkit") { transformObj.setSublistValue({ sublistId: 'item', fieldId: 'quantity', line: j, value: commitQty }); console.log("Enter Into Child Kit"); var invDetailRecObj = transformObj.getSublistSubrecord({ sublistId: 'item', fieldId: 'inventorydetail', line: j }); console.log("Inventory Detail Obj:", JSON.stringify(invDetailRecObj)); invDetailRecObj.setValue({ fieldId: 'quantity', value: parseFloat(commitQty) }); var invtNumId = itemFulfillLineArr[j].inventoryNumDetail[0].srcItemInvtNumId; console.log("invtNumId Fetch:", invtNumId); invDetailRecObj.setSublistValue({ sublistId: "inventoryassignment", fieldId: "issueinventorynumber", line: 0, value: invtNumId }); console.log("invtNumId Set"); invDetailRecObj.setSublistValue({ sublistId: "inventoryassignment", fieldId: "inventorystatus", line: 0, value: 1 }); console.log("Inventory Status Set"); invDetailRecObj.setSublistValue({ sublistId: "inventoryassignment", fieldId: "quantity", line: 0, value: commitQty }); console.log("Inventory Quantity Set"); } } } var transObjSaveId = transformObj.save(); console.log('transObjSaveId', transObjSaveId); } catch (error) { console.error("Error Into Client Script:", error); } } return { pageInit: pageInit, createFulfillment: createFulfillment } });
c
From the snippet you've posted, it's impossible to tell where the issue is. I would guess it's going to be one of these is null: transformObj or invDetailRecObj
If you added some basic error checking/handling; you'd be able to locate the issue easier and handle it gracefully in production.
b
first off, you have a unnecessary nested loop
nested loops are a source of complexity that you really want to avoid
so you need to ask yourself why you are looping over every
itemFulfillLineArr
line for every single line (on the fulfillment?)
on the netsuite knowledge side, you have the wrong id for the fulfill checkbox
you need to take a closer look at the fields on an existing fulfillment, dont guess ids
in general if you are getting weird looking errors in clientside suitescript, try it in a serverside script first
i would actually recommend making a suitelet to create the item fulfillment instead, and then make the client script make a request to the suitelet
but if you really want to continue clientside, the other thing to try is using dynamic mode, which usually has more helpful error messages