我已经获得了普通的事务搜索,SOAP看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<search xsi:type="sales:TransactionSearch"
xmlns="urn:messages_2013_1.platform.webservices.netsuite.com"
xmlns:sales="urn:sales_2013_1.transactions.webservices.netsuite.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:common="urn:common_2013_1.platform.webservices.netsuite.com"
xmlns:core="urn:core_2013_1.platform.webservices.netsuite.com">
<sales:basic xsi:type="common:TransactionSearchBasic" xmlns:common="urn:common_2013_1.platform.webservices.netsuite.com">
<common:type operator="anyOf" xsi:type="core:SearchEnumMultiSelectField">
<core:searchValue xsi:type="xsd:string">_invoice</core:searchValue>
</common:type>
<common:customFieldList xsi:type="core:SearchCustomFieldList">
<core:customField operator="anyOf" xsi:type="core:SearchMultiSelectCustomField" internalId="custbodyintegrationstatus">
<core:searchValue xsi:type="core:ListOrRecordRef" internalId="1" name="customlistintegrationstatuses"></core:searchValue>
</core:customField>
</common:customFieldList>
</sales:basic>
</search>
此搜索现在可以在生产中使用,但有时当我运行此搜索时,我会得到结果中的UNEXPECTED_ERROR。所以来自NetSuite的人建议使用高级搜索。 我们的想法是找到所有具有预定义的自定义字段值的发票,称为custbodyintegrationstatus。自定义字段是值列表,我需要使用internalId =&#34; 1&#34;选择值。对于每个找到的发票,我唯一需要的是internalId。 问题是我不知道该怎么做。这是我的代码(C#):
TransactionSearchAdvanced advancedSearchEntity = new TransactionSearchAdvanced();
TransactionSearch ts = new TransactionSearch();
TransactionSearchBasic tsb = new TransactionSearchBasic();
// condition 1: on SO only
SearchEnumMultiSelectField semsfTranType = new SearchEnumMultiSelectField();
semsfTranType.operatorSpecified = true;
semsfTranType.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
semsfTranType.searchValue = new[]{"_salesOrder"};
SearchMultiSelectCustomField spsIntegrationStatusField = new SearchMultiSelectCustomField();
spsIntegrationStatusField.operatorSpecified = true;
spsIntegrationStatusField.@operator = SearchMultiSelectFieldOperator.anyOf;
spsIntegrationStatusField.internalId = "custbodyintegrationstatus";
ListOrRecordRef searchRecordEntity = new ListOrRecordRef();
searchRecordEntity.name = "customlistintegrationstatuses";
searchRecordEntity.internalId = "1"; // indicates record status - ready / test ready / etc
spsIntegrationStatusField.searchValue = new[] { searchRecordEntity };
tsb.type = semsfTranType;
tsb.customFieldList = new SearchCustomField[] { spsIntegrationStatusField };
TransactionSearchRow tsr = new TransactionSearchRow();
TransactionSearchRowBasic tsrb = new TransactionSearchRowBasic();
SearchColumnSelectField[] selcols = new SearchColumnSelectField[1];
selcols[0] = new SearchColumnSelectField();
// Set return columns
tsrb.internalId = selcols;
tsr.basic = tsrb;
ts.basic = tsb;
advancedSearchEntity.criteria = ts;
advancedSearchEntity.columns = tsr; //note - columns previously defined above.
_service.searchPreferences.returnSearchColumns = true;
SearchResult savedSearchResult = _service.search(advancedSearchEntity);
WebServices Usage日志中的SOAP请求如下所示:
<search xmlns="urn:messages_2013_1.platform.webservices.netsuite.com">
<searchRecord xsi:type="q1:TransactionSearchAdvanced" xmlns:q1="urn:sales_2013_1.transactions.webservices.netsuite.com">
<q1:criteria>
<q1:basic>
<type operator="anyOf" xmlns="urn:common_2013_1.platform.webservices.netsuite.com">
<searchValue xmlns="urn:core_2013_1.platform.webservices.netsuite.com">_salesOrder</searchValue>
</type>
<customFieldList xmlns="urn:common_2013_1.platform.webservices.netsuite.com">
<customField operator="anyOf" internalId="custbodyintegrationstatus" xsi:type="SearchMultiSelectCustomField" xmlns="urn:core_2013_1.platform.webservices.netsuite.com">
<searchValue internalId="1">
<name>customlistintegrationstatuses</name>
</searchValue>
</customField>
</customFieldList>
</q1:basic>
</q1:criteria>
<q1:columns>
<q1:basic>
<internalId xmlns="urn:common_2013_1.platform.webservices.netsuite.com"/>
</q1:basic>
</q1:columns>
</searchRecord>
</search>
以下是回复:
<searchResponse xmlns="urn:messages_2013_1.platform.webservices.netsuite.com">
<platformCore:searchResult xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com">
<platformCore:status isSuccess="true"/>
<platformCore:totalRecords>108956</platformCore:totalRecords>
<platformCore:pageSize>5</platformCore:pageSize>
<platformCore:totalPages>21792</platformCore:totalPages>
<platformCore:pageIndex>1</platformCore:pageIndex>
<platformCore:searchId>WEBSERVICES_TSTDRV961603_060120141461034810519911044_b227f55</platformCore:searchId>
<platformCore:searchRowList>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2013_1.transactions.webservices.netsuite.com">
<tranSales:basic xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com">
<platformCommon:internalId>
<platformCore:searchValue internalId="134200"/>
</platformCommon:internalId>
</tranSales:basic>
</platformCore:searchRow>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2013_1.transactions.webservices.netsuite.com">
<tranSales:basic xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com">
<platformCommon:internalId>
<platformCore:searchValue internalId="134200"/>
</platformCommon:internalId>
</tranSales:basic>
</platformCore:searchRow>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2013_1.transactions.webservices.netsuite.com">
<tranSales:basic xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com">
<platformCommon:internalId>
<platformCore:searchValue internalId="134200"/>
</platformCommon:internalId>
</tranSales:basic>
</platformCore:searchRow>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2013_1.transactions.webservices.netsuite.com">
<tranSales:basic xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com">
<platformCommon:internalId>
<platformCore:searchValue internalId="134200"/>
</platformCommon:internalId>
</tranSales:basic>
</platformCore:searchRow>
<platformCore:searchRow xsi:type="tranSales:TransactionSearchRow" xmlns:tranSales="urn:sales_2013_1.transactions.webservices.netsuite.com">
<tranSales:basic xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com">
<platformCommon:internalId>
<platformCore:searchValue internalId="134255"/>
</platformCommon:internalId>
</tranSales:basic>
</platformCore:searchRow>
</platformCore:searchRowList>
</platformCore:searchResult>
</searchResponse>
很明显,我做错了什么,即使搜索行中没有排队的internalIds也表明了这一点。那么,请告诉我有什么问题。 SOAP或任何C#/ Java / etc代码示例都非常有用。
答案 0 :(得分:1)
尝试添加搜索过滤器主线= T以删除重复项。你实际上还有一个internalid = 1的记录吗?
答案 1 :(得分:0)
<search xmlns="urn:messages_2013_1.platform.webservices.netsuite.com">
<searchRecord xsi:type="q1:TransactionSearchAdvanced" xmlns:q1="urn:sales_2013_1.transactions.webservices.netsuite.com">
<q1:criteria>
<q1:basic>
<mainLine xmlns="urn:common_2013_1.platform.webservices.netsuite.com">
<searchValue xmlns="urn:core_2013_1.platform.webservices.netsuite.com">true</searchValue>
</mainLine>
<type operator="anyOf" xmlns="urn:common_2013_1.platform.webservices.netsuite.com">
<searchValue xmlns="urn:core_2013_1.platform.webservices.netsuite.com">_salesOrder</searchValue>
</type>
<customFieldList xmlns="urn:common_2013_1.platform.webservices.netsuite.com">
<customField operator="anyOf" internalId="custbodyintegrationstatus" xsi:type="SearchMultiSelectCustomField" xmlns="urn:core_2013_1.platform.webservices.netsuite.com">
<searchValue internalId="2">
<name>customlistintegrationstatuses</name>
</searchValue>
</customField>
</customFieldList>
</q1:basic>
</q1:criteria>
<q1:columns>
<q1:basic>
<internalId xmlns="urn:common_2013_1.platform.webservices.netsuite.com"/>
</q1:basic>
</q1:columns>
</searchRecord>
</search>