NetSuite Contact Advanced Search via SOAP API – Can’t use “type” in criteria
I am working on a data migration process to extract data from netsuite and push it into an eCommerce platorm. One of the record types we want to migrate is the Contact record. In a nutshell, we want to create user profiles using the Contact email as the username, and associate it to the appropriate customers.
So, I am writing an advanced search on which I would like to have the following criteria:
- Inactive = false
- Type = Customer
This is easy enough to do when building a saved search in the Netsuite UI, but it appears that the “type” criteria is not working via the SOAP API (version 2022_2). Further, it does not seem to be exposed to the API as a search result field (even though it is listed as a Search Column in the schema browser for the Contact entity type)
Here is the C# code I am currently using to try to execute this search:
var csa = new ContactSearchAdvanced()
{
//savedSearchId = savedSearchId,
criteria = new ContactSearch()
{
basic = new ContactSearchBasic()
{
type = new SearchEnumMultiSelectField()
{
@operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new[] { "Customer" }
},
isInactive = new SearchBooleanField
{
searchValue = false,
searchValueSpecified = true
}
}
},
columns = new ContactSearchRow()
{
basic = new ContactSearchRowBasic
{
internalId = new[] { new SearchColumnSelectField() },
externalId = new[] { new SearchColumnSelectField() },
firstName = new[] { new SearchColumnStringField() },
lastName = new[] { new SearchColumnStringField() },
phone = new[] { new SearchColumnStringField() },
fax = new[] { new SearchColumnStringField() },
email = new[] { new SearchColumnStringField() },
altEmail = new[] { new SearchColumnStringField() },
title = new[] { new SearchColumnStringField() },
customFieldList = new SearchColumnCustomField[]
{
new SearchColumnStringCustomField()
{
scriptId = "custentity_contact_compname"
}
}
}
}
};
When I run this, I get: “The field type’s enum value is invalid for this search.”
I’ve also tried using what I believe would be the internal enum value of “_customer”, which resolves the error but gives 0 results still.
Also worth noting: we have a similar search against “Transaction” record in which we are filtering on the type = invoice without any issue.
Of course I can just set up a saved search and use that as the base for filtration purposes, and then override the columns I’m selecting but I’m curious why this isn’t working and why the “type” is not a field that gets returned with Contact searches in general. Has anyone else encountered this issue, maybe I’m missing something obvious?
Some additional information I found – https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N3518134.html
I also located the ContactType in the XSD (from my WSDL reference), it does exist as a SimpleType but does not appear to be referenced anywhere else:
<xsd:simpleType name="ContactType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="_customer" />
<xsd:enumeration value="_employee" />
<xsd:enumeration value="_otherName" />
<xsd:enumeration value="_partner" />
<xsd:enumeration value="_vendor" />
</xsd:restriction>
</xsd:simpleType>



