SuiteScript技术问题:如何查询库存调拨子记录的字段ID
Got it, let's figure out how to get those subrecord line item field IDs for your bin transfer Restlet. Here are the most straightforward methods I've used in NetSuite:
- Navigate to the Bin Transfer form (Transactions > Inventory > Bin Transfers) and start creating a new transfer.
- Hover over the label of the subrecord field you need (like inventory detail bin or quantity), right-click, and select "Inspect" (using Chrome/Firefox dev tools). Look for the
idattribute of the associated input element – it’ll typically be formatted likeinventorydetail_<fieldid>or just the raw field ID itself. - If you have Customization Mode enabled (Setup > Company > Enable Features > SuiteCloud > Customization), click the field label and select "Customize Field" – the field ID will be prominently displayed at the top of the field setup page.
- Go to Setup > Integration > REST API Browser.
- Search for the
binTransferrecord type, expand it, and locate the subrecord you’re working with (likeinventoryDetailor the line item sublist). - Click into the subrecord, and you’ll see a full list of available fields with their official IDs – this is perfect because it directly maps to the structure you need for your Restlet payload.
If the UI methods don’t work, whip up a quick SuiteScript 2.x snippet to load a sample bin transfer and log the subrecord fields:
require(['N/record'], function(record) { // Replace 123 with a valid existing bin transfer ID var binTransfer = record.load({ type: record.Type.BIN_TRANSFER, id: 123 }); var lineCount = binTransfer.getLineCount({sublistId: 'inventory'}); if (lineCount > 0) { var inventoryDetail = binTransfer.getSublistSubrecord({ sublistId: 'inventory', fieldId: 'inventorydetail', line: 0 }); var subFieldIds = inventoryDetail.getFields(); log.debug('Inventory Detail Field IDs', subFieldIds); } });
Deploy this as a scheduled script or scriptlet, run it, and check the script logs – it’ll spit out every field ID for that subrecord.
If you have access, go to Customization > Workbook > Customization Workbook. Search for the Bin Transfer record, drill down to the target subrecord, and you’ll find a complete list of fields with their IDs.
Once you have the correct field IDs, you can structure your Restlet payload to include them in the subrecord section. For example:
{ "inventory": [ { "item": 456, "quantity": 10, "inventoryDetail": { "inventoryAssignment": [ { "bin": 789, "quantity": 10 } ] } } ] }
内容的提问来源于stack exchange,提问作者jebeeee

