Write a SuiteScript 2.x script to set lot number and bin assignments on an Item Receipt subrecord (InventoryDetail) when receiving components against a work order
domain: docs.oracle.com/en/cloud/saas/netsuite · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
NetSuite SuiteTalk REST authentication — the full failure-mode walkthrough related to docs.oracle.com/en/cloud/saas/netsuite, checked against official docs, with linked verified routes.
Steps
Load or create the item receipt record in dynamic mode: var rec = record.load({type: record.Type.ITEM_RECEIPT, id: receiptId, isDynamic: true}).
Select the target line using rec.selectLine({sublistId: 'item', line: lineIndex}) before accessing the inventory detail subrecord.
Get the subrecord: var invDetail = rec.getCurrentSublistSubrecord({sublistId: 'item', fieldId: 'inventorydetail'}).
Commit the parent line with rec.commitLine({sublistId: 'item'}) after setting the subrecord, then call rec.save().
Validate that the feature 'MULTILOCINVT' or 'LOTNUMBEREDINVENTORY' is enabled for the item; otherwise the inventorydetail subrecord field will be null.
Known gotchas
Subrecords in NetSuite REST API (non-SuiteScript) have a different access pattern — you cannot use getCurrentSublistSubrecord via REST; instead POST the subrecord body inline using the nested subrecord endpoint.
Calling rec.getSubrecord instead of rec.getCurrentSublistSubrecord when in dynamic mode returns a body-level subrecord, not a sublist-line subrecord — they are different fields and the error is silent.
The field ID for the lot number on receipt is receiptinventorynumber, not inventorynumber — using the wrong field ID silently stores nothing and the lot is left unassigned.
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?