gpt4 book ai didi

netsuite - SuiteTalk 高级搜索示例

转载 作者:行者123 更新时间:2023-12-02 20:34:33 31 4
gpt4 key购买 nike

我使用 NetSuite 和 SuiteTalk 的时间还不到一年。我找到了利用已保存搜索的基本搜索和高级搜索的示例,但我很难找到如何使用结果集中的条件和选定列从头开始执行高级搜索的示例。所以我要求提供示例。

最佳答案

我查看了可从 NetSuite 下载的 NSClientERP 项目中提供的示例。这是一个简化的示例。

        service.searchPreferences = new SearchPreferences();
service.searchPreferences.bodyFieldsOnly = true;
service.searchPreferences.returnSearchColumns = true;

TransactionSearchAdvanced customSearch = new TransactionSearchAdvanced()
{
columns = new TransactionSearchRow()
{
basic = new TransactionSearchRowBasic()
{
dateCreated = new SearchColumnDateField[] { new SearchColumnDateField() }
, tranDate = new SearchColumnDateField[] { new SearchColumnDateField() }
, type = new SearchColumnEnumSelectField[] { new SearchColumnEnumSelectField() }
, tranId = new SearchColumnStringField[] { new SearchColumnStringField() }
, internalId = new SearchColumnSelectField[] { new SearchColumnSelectField() }
, entity = new SearchColumnSelectField[] { new SearchColumnSelectField() }
, item = new SearchColumnSelectField[] { new SearchColumnSelectField() }
, lastModifiedDate = new SearchColumnDateField[] { new SearchColumnDateField() }
}
, itemJoin = new ItemSearchRowBasic()
{
itemId = new SearchColumnStringField[] { new SearchColumnStringField() }
}
}
,
criteria = new TransactionSearch()
{
basic = new TransactionSearchBasic()
{
type = new SearchEnumMultiSelectField()
{
@operator = SearchEnumMultiSelectFieldOperator.anyOf
, operatorSpecified = true
, searchValue = new string[] {
"_salesOrder"
}
}
, lastModifiedDate = new SearchDateField()
{
@operator = SearchDateFieldOperator.onOrAfter
, operatorSpecified = true
, searchValue = DateTime.Now.AddDays(-3)
, searchValueSpecified = true
}
}
}
};

Console.WriteLine("Querying NetSuite");

SearchResult searchResult = service.search(customSearch);

Console.WriteLine("Query Results: " + searchResult.totalRecords.ToString());
int total = searchResult.totalRecords;
int updated = 0;
bool searchMore = false;


Console.WriteLine("\nThe search() operation for transaction was run successfully.");
Console.WriteLine("\n Total Records = " + searchResult.totalRecords);
Console.WriteLine(" Total Pages = " + searchResult.totalPages);
Console.WriteLine(" Page Size = " + searchResult.pageSize);
Console.WriteLine(" Current Page Index = " + searchResult.pageIndex);

Console.WriteLine("\n\nHit Enter to list results");
Console.ReadLine();

SearchRow[] records = searchResult.searchRowList;

if (records != null)
{
for (int i = 0, j = (searchResult.pageIndex - 1) * searchResult.pageSize; i < records.Length; i++, j++)
{
TransactionSearchRow transactionRow = (TransactionSearchRow) records[i];
TransactionSearchRowBasic transactionRowBasic = transactionRow.basic;
ItemSearchRowBasic itemRowBasic = transactionRow.itemJoin;
Console.WriteLine(
"\n Transaction Return Columns Row[" + j + "]: " +
"\n internalId=" + transactionRowBasic.internalId[0].searchValue.internalId +
"\n tranId=" + transactionRowBasic.tranId[0].searchValue +
"\n type=" + transactionRowBasic.type[0].searchValue +
(transactionRowBasic.entity == null ? "" : ("\n customer internalID=" + transactionRowBasic.entity[0].searchValue.internalId)) +
(transactionRowBasic.item == null ? "" : ("\n item=" + transactionRowBasic.item[0].searchValue.internalId)) +
(itemRowBasic == null ? "" : ("\n item.name=" + itemRowBasic.itemId[0].searchValue)) +
(transactionRowBasic.dateCreated == null ? "" : ("\n createdDate=" + transactionRowBasic.dateCreated[0].searchValue.ToString()) +
(transactionRowBasic.tranDate == null ? "" : ("\n tranDate=" + transactionRowBasic.tranDate[0].searchValue.ToString())) +
(transactionRowBasic.lastModifiedDate == null ? "" : ("\n lastModifiedDate=" + transactionRowBasic.lastModifiedDate[0].searchValue.ToString()))));
}
}

在执行高级搜索之前设置您的搜索首选项非常重要。如果没有将 returnSearchFields 设置为 true,我没有得到任何结果。此外,您还必须提供条件和列。在 NSClientERP 示例中,以 TransactionSearchAdvanced 开头的每个对象都在单独的代码行中实例化、配置并链接到子对象。我发现这很难理解。我使用一行代码来实例化整个搜索对象。

另一个需要注意的是 itemJoin,它将 Items 表连接到销售订单行项目。您还可以使用其他联接,例如 billingTransactionJoin。利用这些联接,您可以访问关联的表来获取商品的显示名称、库存信息或商品发货时的跟踪号码等信息。

除了填充数据集并事后排序之外,我一直无法找到对结果进行排序的方法。如果有人有更好的方法,请告诉我。

关于netsuite - SuiteTalk 高级搜索示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47534845/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com