I have two custom objects. The parent object is an Order
, and it has a list of type Part
associated with it. I'm trying to get the list of Parts
with a value "Inventory Item" in one field, but only for a particular Order
.
I have the name
and numeric internalId
of the Order
available,but the problem is those aren't (as far as I can tell) searchable "fields", there is no "internalId" to provide to tell it to search on one of those.
In the code below, if I don't include the attempt to search on the Order it works fine. I can get all the Parts
with a type of "Inventory Item".
I think I need to use a joined search? My attempt at it is below. This produces a SOAP error at runtime:
Additional information: org.xml.sax.SAXException: 'customizationRef' on
{urn:common_2015_1.platform.webservices.netsuite.com}CustomSearchJoin is
required
Code
private static SearchResult NetSuiteSearchOrderItems(NetSuiteService netSuiteService, string order_name, string order_internalId)
{
CustomRecordSearch searchParts = new CustomRecordSearch();
CustomRecordSearchBasic basicRecordSearchParts = new CustomRecordSearchBasic();
basicRecordSearchParts.recType = new RecordRef { internalId = "64" }; //"Order Item" NetSuite Type ID
//adding a search filter on a String Custom Field
SearchStringCustomField partTypeFieldSearch = new SearchStringCustomField();
partTypeFieldSearch.@operator = SearchStringFieldOperator.@is;
partTypeFieldSearch.internalId = "896"; //ID of the Part object's "Type" field
partTypeFieldSearch.operatorSpecified = true;
partTypeFieldSearch.searchValue = "Inventory Item"; //only want inventory item parts
//Show me only parts on a certain Order
CustomSearchJoin orderSearchJoin = new CustomSearchJoin();
CustomRecordSearchBasic orderBasicSearch = new CustomRecordSearchBasic();
orderBasicSearch.recType = new RecordRef { internalId = "56" }; //"Order" NetSuite Type ID
//-- WHAT GOES HERE INSTEAD OF SearchStringCustomField?
//adding a search filter on a String Custom Field
SearchStringCustomField fsoItemTypeSearch = new SearchStringCustomField();
fsoItemTypeSearch.@operator = SearchStringFieldOperator.@is;
fsoItemTypeSearch.internalId = "name"; //I have the "name" and numeric "internal id" of the order available.
fsoItemTypeSearch.operatorSpecified = true;
fsoItemTypeSearch.searchValue = order_name;//search filter value
orderSearchJoin.searchRecordBasic = orderBasicSearch;
//add in the things we want to search on
basicRecordSearchParts.customFieldList = new SearchCustomField[] { partTypeFieldSearch };
//add the basic search and join search and then perform the search
searchParts.basic = basicRecordSearchParts;
searchParts.customSearchJoin = new CustomSearchJoin[] { orderSearchJoin };
SearchResult response = netSuiteService.search(searchParts);
return response;
}