问题
I'm using C# in VS 2013.
I use this code:
var request = new ItemSearchBasic
{
type = new SearchEnumMultiSelectField
{
searchValue = new string[]
{
"_inventoryItem"
},
@operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true
}
};
and I get not just inventory items but other types of item too.
My soap request looks like this:
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<passport xmlns="urn:messages_2014_2.platform.webservices.netsuite.com">
<email xmlns="urn:core_2014_2.platform.webservices.netsuite.com">xxxxxxxxx</email>
<password xmlns="urn:core_2014_2.platform.webservices.netsuite.com">********************</password>
<account xmlns="urn:core_2014_2.platform.webservices.netsuite.com">xxxxxxxxx</account>
<role internalId="3" xmlns="urn:core_2014_2.platform.webservices.netsuite.com"/>
</passport>
<searchPreferences xmlns="urn:messages_2014_2.platform.webservices.netsuite.com">
<bodyFieldsOnly>false</bodyFieldsOnly>
<pageSize>5</pageSize>
</searchPreferences>
</soap:Header>
<soap:Body>
<search xmlns="urn:messages_2014_2.platform.webservices.netsuite.com">
<searchRecord xsi:type="q1:ItemSearchBasic" xmlns:q1="urn:common_2014_2.platform.webservices.netsuite.com">
<q1:type operator="anyOf">
<searchValue xmlns="urn:core_2014_2.platform.webservices.netsuite.com">_inventoryItem</searchValue>
</q1:type>
</searchRecord>
</search>
</soap:Body>
</soap:Envelope>
The NetSuite help does't mention how to filter by item type and I've guessed this method from various non-NetSuite web pages.
If I remove the filter on type then my search returns inventoryItem, serializedInventoryItem, lotNumberedInventoryItem and nonInventoryPurchaseItem.
If I use the _inventoryItem filter then I get inventoryItem, serializedInventoryItem and lotNumberedInventoryItem. So maybe NetSuite considers serializedInventoryItem and lotNumberedInventoryItem to both be inventoryItem.
回答1:
If you need to distinguish (Inventory) Items in more detail, you can use 'isSerialItem', 'isLotItem' and 'subType' (for purchase/resale/sale) search filters in the search request.
来源:https://stackoverflow.com/questions/27628083/how-to-search-for-only-inventory-items-using-suitetalk