# NetSuite Import - Transfer Order - Inventory Details

**URL:** <https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791>\
**Category:** Integrator.io\
**Tags:** netsuite, import\
**Created:** [March 13, 2025, 11:42am UTC](https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791 "2025-03-13T11:42:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielhalawi](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@danielhalawi](https://connective.celigo.com/u/danielhalawi)\
**Post date:** [March 13, 2025, 11:42am UTC](https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791/1 "2025-03-13T11:42:31Z")

</div>

Hey,

Can anyone point me in the right direction of being able to assign Inventory Detail to item lines on a Transfer Order Import?

The transfer order type doesn't allow for me to add a subrrecord like it does on Item Fulfilments. Our requirement is that Inventory Details are assigned at the Transfer Order level first before creating an Item Fulfilment.

**Transfer Order:**

 ![A form interface for importing records with options to add or update a "Transfer Order" record type. (Captioned by AI)](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/6/6b62be89521ac00135a80d1144407883c567b613.png)

**Item Fulfillment:**

 ![A form interface for importing records, specifying "Item Fulfillment" as the record type with the operation set to "Add." (Captioned by AI)](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/e/ea479091708959ca60eb612fe9d483955204cfe4.png)

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [March 13, 2025, 2:53pm UTC](https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791/2 "2025-03-13T14:53:23Z")

</div>

You would need to use subrecords: [https://docs.celigo.com/hc/en-us/articles/360016510891-Configure-and-map-NetSuite-subrecords](https://docs.celigo.com/hc/en-us/articles/360016510891-Configure-and-map-NetSuite-subrecords)

---

<div class="post-metadata">

**Author:** ![danielhalawi](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@danielhalawi](https://connective.celigo.com/u/danielhalawi)\
**Post date:** [March 13, 2025, 3:15pm UTC](https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791/3 "2025-03-13T15:15:53Z")

</div>

Hi Tyler,

Thanks, the subrecord import is not available for me to add to Transfer Order via the UI.

 ![A form interface asks how records should be imported, with options for "Record type" and "Operation," currently set to "Transfer Order" and "Add," respectively. (Captioned by AI)](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/8/8520486a8ba14459b39f213bd451b457822e82f8.png)

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [March 13, 2025, 3:24pm UTC](https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791/4 "2025-03-13T15:24:33Z")

</div>

Looks like this would need an enhancement then. For now, you would need to use a postMap SuiteScript hook:

- [SuiteScript-Hooks/postMap at master · CeligoServices/SuiteScript-Hooks · GitHub](https://github.com/CeligoServices/SuiteScript-Hooks/tree/master/postMap)
- [https://docs.celigo.com/hc/en-us/articles/27548857134107-NetSuite-SuiteScript-hooks](https://docs.celigo.com/hc/en-us/articles/27548857134107-NetSuite-SuiteScript-hooks)

@praveenbasani @muneswarathotakura I see TransferOrderItem has a commitInventory subrecord, and it looks like we don't have it available here: [https://www.netsuite.com/help/helpcenter/en\_US/srbrowser/Browser2016\_1/schema/other/transferorderitem.html?mode=package](https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/schema/other/transferorderitem.html?mode=package).

---

<div class="post-metadata">

**Author:** ![danielhalawi](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@danielhalawi](https://connective.celigo.com/u/danielhalawi)\
**Post date:** [March 14, 2025, 9:13am UTC](https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791/5 "2025-03-14T09:13:46Z")

</div>

Thanks Tyler.

For anyone who lands on this looking for a solution, I used a SuiteScript Hook...

I had to change my NetSuite import to SuiteScript version 1.

 ![The image shows an advanced settings menu for selecting the NetSuite API version, offering options for "SuiteApp SuiteScript 2.x (Recommended)" and "SuiteApp SuiteScript 1.0," with the latter selected. (Captioned by AI)](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/8/8702cc568da9306c9c04de29699f260cd7097639.png)

Updated my mapping to include the lot and qty for the batches in the item lines.

 ![The image shows a table with rows and columns, featuring labels like "items[].internalId," "items[].quantity," and others, some of which are highlighted with a red border. (Captioned by AI)](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/8/881ac5b6a4d794435a4d409282a236fdb34ac43d.png)

The following the example at [SuiteScript-Hooks/postMap/itemLotNumbersImport.js at master · CeligoServices/SuiteScript-Hooks · GitHub](https://github.com/CeligoServices/SuiteScript-Hooks/blob/master/postMap/itemLotNumbersImport.js) adjusted the script as follows:

### **🔹 How the Script Works:**

1. **Receives the `options.postMapData` Input**

- This data contains the Transfer Order details, including **item lines** with quantities and lot numbers.
- Logs the **raw input data** before processing.

1. **Loops Through All Items in the Transfer Order**

- Extracts each **item’s lot number and quantity**.
- If no lot number exists, logs an error and adds an error message.
- Otherwise, it creates **inventory detail lines** for each lot number.

1. **Adds Inventory Detail to Each Item**

- Creates an `inventorydetail` object for items that need it.
- Attaches the lot number(s) and quantities under `inventoryassignment`.

1. **Final Validation Before Submission**

- Checks that **all items** have `inventorydetail` properly mapped.
- If any item is missing its inventory detail, it **logs an error and throws an exception** to prevent incorrect data from being submitted.

1. **Returns the Modified Data**

- If everything is correct, the script returns the modified Transfer Order data with the correct inventory details attached.

### **🔹 Key Features & Benefits**

✅ **Handles Multiple Items** – Ensures that every item in a Transfer Order gets the correct inventory details.  
✅ **Error Logging & Debugging** – Logs missing lot numbers and inventory detail issues for easy debugging.  
✅ **Prevents Data Loss** – Ensures that NetSuite retains inventory details before submitting the Transfer Order.  
✅ **Ensures Compliance** – If NetSuite ignores inventory details, the script stops the process and alerts the user.

> var itemLotNumbersImport = function (options) {  
> var response = ;
> 
> ```
> nlapiLogExecution('AUDIT', '🔄 PostMap Options (Before Processing)', JSON.stringify(options));
> 
> for (var i = 0; i < options.postMapData.length; i++) {
> response.push({
> data: JSON.parse(JSON.stringify(options.postMapData[i])),
> errors: []
> });
> }
> 
> try {
> nlapiLogExecution('AUDIT', '🔄 PostMap Data Before Modification', JSON.stringify(response));
> 
> for (var i = 0; i < response.length; i++) {
> var configObject = response[i].data;
> var errors = response[i].errors;
> var itemLinesObject = configObject.nlobjSublistIds.item || {};
> var itemLines = itemLinesObject.lines || [];
> 
> for (var j = 0; j < itemLines.length; ++j) {
> var isLotItem = itemLines[j].custcol_is_lot_item || 'T'; // Assume 'T' if missing
> var lotNumbers = itemLines[j].lot ? [{ lot: itemLines[j].lot, qty: itemLines[j].qty }] : [];
> 
> nlapiLogExecution('DEBUG', '🔍 Lot Numbers Extracted for Item ' + j, JSON.stringify(lotNumbers));
> 
> if (isLotItem === 'T') {
> if (!lotNumbers.length) {
> errors.push({
> code: 'NO_LOT_NUMBER',
> message: 'No Lot Numbers found to import for item ' + j
> });
> nlapiLogExecution('ERROR', '❌ Missing Lot Number', 'Item ' + j + ': ' + JSON.stringify(itemLines[j]));
> } else {
> var inventoryDetailLines = [];
> 
> for (var k = 0; k < lotNumbers.length; k++) {
> inventoryDetailLines.push({
> "quantity": lotNumbers[k].qty,
> "issueinventorynumber": lotNumbers[k].lot
> });
> nlapiLogExecution('DEBUG', '✅ Processing Lot Number for Item ' + j, JSON.stringify(lotNumbers[k]));
> }
> 
> itemLines[j].celigo_inventorydetail = {
> "nlobjRecordType": "inventorydetail",
> "nlobjFieldIds": { "celigo_recordmode_dynamic": true },
> "nlobjSublistIds": {
> "inventoryassignment": { "lines": inventoryDetailLines }
> }
> };
> 
> nlapiLogExecution('AUDIT', '✅ Mapped Inventory Detail for Item ' + j, JSON.stringify(itemLines[j].celigo_inventorydetail));
> }
> }
> 
> delete itemLines[j].custcol_is_lot_item;
> }
> }
> 
> nlapiLogExecution('AUDIT', '✅ PostMap Data After Modification', JSON.stringify(response));
> 
> } catch (e) {
> nlapiLogExecution('ERROR', '❌ Script Error', e.name + ': ' + e.message);
> for (var i = 0; i < response.length; i++) {
> response[i].data = null;
> response[i].errors.push({
> code: e.name,
> message: e.message
> });
> }
> }
> 
> // 🚨 Final check before submission for all items
> for (var i = 0; i < response.length; i++) {
> var record = response[i].data;
> var itemLines = record.nlobjSublistIds.item.lines || [];
> 
> for (var j = 0; j < itemLines.length; j++) {
> if (!itemLines[j].celigo_inventorydetail || 
> !itemLines[j].celigo_inventorydetail.nlobjSublistIds.inventoryassignment.lines.length) {
> nlapiLogExecution('ERROR', '❌ NetSuite Ignored Inventory Detail Before Submission for Item ' + j, JSON.stringify(itemLines[j]));
> throw new Error('NetSuite did not retain inventorydetail on Transfer Order.');
> }
> }
> }
> 
> return response;
> 
> ```
> 
> };

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [March 14, 2025, 2:03pm UTC](https://connective.celigo.com/t/netsuite-import-transfer-order-inventory-details/3791/6 "2025-03-14T14:03:56Z")

</div>

There are also SS 2.0 examples here: [SuiteScript-Hooks/SuiteScript2/PostMap at master · CeligoServices/SuiteScript-Hooks · GitHub](https://github.com/CeligoServices/SuiteScript-Hooks/tree/master/SuiteScript2/PostMap). Glad you got this working!
