Hi All, How to read the Inventory Details field wh...
# suitescript
a
Hi All, How to read the Inventory Details field when you view the subrecord from parent record in SS2.0?
b
have you tried something like
oParent.getSublists();
And then you can do a
oParent.getSublistFields("inventorydetail")
or whatever to interrogate it further. Also sublists APIs are slightly different depending on whether you are loading the record as
Dynamic
vs
Deferred Dynamic
modes.
b
depends on what record and what subrecord you are working with, but in general the subrecord is basically a record
👍 1
use getValue for body fields and getSublistValue for sublist fields
if you know how to translate ss1 to ss2, ss1 documentation for inventory details is better than ss2.
a
it works basically you have to load the record and it will act as normal record
var objSubRecord = currentRecord.getSublistSubrecord({ sublistId: 'item', fieldId: 'inventorydetail', line: j }); log.debug("serial Number",JSON.stringify(objSubRecord)); var lineCountInvDetail = objSubRecord.getLineCount({ sublistId: 'inventoryassignment' });
s
doing this with NFT is intuitive - access is just
rec.inventorydetail.inventoryassignment
a
@stalbert Have you tried this before ? What is NFT ?
s
yes, I was accessing inventory assignment like this just last week 🙂
👍 1
the github repo is linked on that npm page as well.
I'm using it like so:
Copy code
const ia = line.inventorydetail.inventoryassignment.addLine()
          ia.issueinventorynumber = itemToLotMap[line.item] // lot number
          ia.quantity = line.quantity
          log.debug(`added inventory assignment line to SO ${so.id}`, ia)
a
cool