NetSuite Restlet插入Sales Order时Location字段报错求助
Let's work through your two Location-related errors and get your Sales Order creation working correctly.
First Error: "Please enter value(s) for: Location"
Your initial request used a nested object format for the Location field:
{ "recordtype" : "salesorder", "entity" : "142832", "location" : { "id":"395" } }
The problem here is that NetSuite doesn't accept this nested object structure for the location field in most SuiteScript/REST API contexts. Instead, you need to pass the Location ID directly as a string value.
Fix: Update your request to set location to the plain ID string:
{ "recordtype" : "salesorder", "entity" : "142832", "location" : "395" }
This tells NetSuite exactly which Location you want to use, and it will recognize the value instead of treating the field as empty.
Second Error: "Invalid location reference key 390 for subsidiary ."
When you switched to using "location" : "390", the error changed to indicate a subsidiary mismatch. The <NULL> here means your Sales Order wasn't assigned a subsidiary, so NetSuite couldn't verify that Location 390 belongs to the default (or missing) subsidiary.
Locations in NetSuite are tied to specific subsidiaries—you can't use a Location that doesn't belong to the subsidiary assigned to the Sales Order.
Fixes:
- Add the subsidiary to your request: First, look up which subsidiary Location 390 belongs to (go to
Setup > Company > Locationsin NetSuite, find ID 390, and check its Subsidiary field). Then include that subsidiary ID in your request:{ "recordtype" : "salesorder", "entity" : "142832", "location" : "390", "subsidiary" : "YOUR_SUBSIDIARY_ID" // Replace with the actual ID for Location 390's subsidiary } - Verify Location validity: Make sure Location 390 is active (not disabled) and that your role has permission to access both the Location and its associated subsidiary.
Quick Additional Checks
- Double-check that you're using the correct field ID: it's definitely
location, not a variation likelocationid. - Confirm that the Entity (customer) you're using (ID 142832) is associated with the same subsidiary as the Location you're selecting—this can also cause hidden validation issues.
内容的提问来源于stack exchange,提问作者Roy Mustang

