RE: How to set transfer order to received using NetSuite SOAP API?

Hi there! Using the NetSuite SOAP API, I am querying an existing Transfer OrderĀ and in which inventory is being transferred from Location A to Location B. My main objective is to complete the transfer order in full, ie, set the items as received in location B, thus closing the transfer. To do so, I’ve been using the initialize method to set the default values of the Receipt, and than trying to add the Receipt. But on the final call, when trying to add the Receipt, I am getting error:

This record contains duplicated key or keys. Please correct it before next update.

The below sample is the code I am using to do this. 948006 is the ID of the Transfer Order Transaction, and UpdateAPISecurity is just updating the token to connect. Could someone assist?


netSuiteAPIClient = new NetSuitePortTypeClient();


NetSuiteAPISB2.Preferences preferences = new NetSuiteAPISB2.Preferences();

NetSuiteAPISB2.ReadResponse readResponse = new ReadResponse();

NetSuiteAPISB2.WriteResponse writeResponse = new WriteResponse();


InitializeRecord initRecord = new InitializeRecord();

initRecord.reference = new InitializeRef();

initRecord.reference.type = InitializeRefType.transferOrder;

initRecord.reference.internalId = “948006”;

initRecord.reference.typeSpecified = true;

initRecord.type = InitializeType.itemReceipt;


netSuiteAPIClient.initialize(tokenPassport, null, null, preferences, initRecord, out readResponse);




ItemReceipt itemReceipt = (ItemReceipt) readResponse.record;



netSuiteAPIClient.add(tokenPassport, null, null, preferences, itemReceipt, out writeResponse);

Add Comment
1 Answers

The problem was with the internalIDs in the inventoryAssignmentList. The initialise method for some reason sets them all to -1 so if you have more than one item, you get many items with the same internalID, and even though its an invalid ID the API complains. The solution is null them as shown below:

foreach (ItemReceiptItem item in itemReceipt.itemList.item)


if (item.inventoryDetail != null)


foreach (InventoryAssignment invAssignment in item.inventoryDetail.inventoryAssignmentList.inventoryAssignment)


invAssignment.internalId = null;

invAssignment.quantitySpecified = false;




Rookie Answered on August 18, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.