How to check if an item’s Inventory Detail requires setting

I am writing a RESTlet that creates Cash Sales in Dynamic mode. Some of the items we have will need their Inventory Details set, but others, namely Inventory Items, do not. Once they’re added to the order, their bin numbers are automatically set.

In SuiteScript 2.1 how can I determine if an item’s Inventory Detail needs set or not. If it makes a difference or not, this subrecord is on the line of a sublist that was selected with selectNewLine.

I have already tried getting the Inventory Detail record.Field and seeing if its isMandatory is true, but this doesn’t seem to change regardless of whether it needs set or not.

Rookie Asked on February 20, 2026 in How To's.
Add Comment
1 Answer(s)

Do not use record.Field.isMandatory on the Inventory Detail subrecord for this. That only tells you about the field metadata, not whether the current transaction line requires inventory assignment.

In practice, the reliable check is:

  1. Add/select the item line

  2. Read the line-level requirement flag

  3. Only open/populate the inventorydetail subrecord when that flag is true

NetSuite exposes an inventorydetailreq field on item lines in transaction-related mappings, which is the right concept for this decision, and Inventory Detail itself is a subrecord attached to the parent transaction line rather than something you validate independently.

/**
* @NApiVersion 2.1
*/
define([‘N/record’, ‘N/log’], (record, log) => {

function addItemLine(cashSale, lineData) {
cashSale.selectNewLine({ sublistId: ‘item’ });

cashSale.setCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘item’,
value: lineData.item
});

cashSale.setCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘quantity’,
value: lineData.quantity
});

// This is the key check
const inventoryDetailRequired = cashSale.getCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘inventorydetailreq’
});

log.debug(‘inventoryDetailRequired’, {
item: lineData.item,
inventoryDetailRequired
});

if (inventoryDetailRequired) {
const invDetail = cashSale.getCurrentSublistSubrecord({
sublistId: ‘item’,
fieldId: ‘inventorydetail’
});

// Example assignment
invDetail.selectNewLine({ sublistId: ‘inventoryassignment’ });

if (lineData.binNumber) {
invDetail.setCurrentSublistValue({
sublistId: ‘inventoryassignment’,
fieldId: ‘binnumber’,
value: lineData.binNumber
});
}

if (lineData.issueInventoryNumber) {
invDetail.setCurrentSublistValue({
sublistId: ‘inventoryassignment’,
fieldId: ‘issueinventorynumber’,
value: lineData.issueInventoryNumber
});
}

invDetail.setCurrentSublistValue({
sublistId: ‘inventoryassignment’,
fieldId: ‘quantity’,
value: lineData.quantity
});

invDetail.commitLine({ sublistId: ‘inventoryassignment’ });
}

cashSale.commitLine({ sublistId: ‘item’ });
}

return { addItemLine };
});

 

inventorydetailreq should be checked after you set the item on the current line, because NetSuite determines the requirement from the actual item and transaction context.

If inventorydetailreq comes back false, let NetSuite handle the default bin behavior and do not force an Inventory Detail subrecord.

If you want an extra defensive fallback, load the item and inspect whether it is lot-numbered or serialized. Those item types are the usual cases where inventory detail assignment is needed. Inventory Detail is specifically used for bin/serial/lot assignment when Advanced Bin / Numbered Inventory Management is in play. 

So the short answer is:

  • Do not test isMandatory on the subrecord field.

  • Do test the transaction line’s inventory detail request after setting the item.

  • Only call getCurrentSublistSubrecord(‘inventorydetail’) and populate assignments when that flag is true.

Beginner Answered on April 3, 2026.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   SuiteMigration   Become a Sponsor