NetSuite SuiteTalk - 从“SearchColumnSelectField”中检索值字符串

NetSuite SuiteTalk - Retrieve Value String From “SearchColumnSelectField”

假设您正在尝试从 SuiteTalk 访问一个 returned 类型为 "SearchColumnSelectField":

的值
((TransactionSearchRow)row).basic.postingPeriod?[0].searchValue.name

注意:我以 postingPeriod 为例,但还有许多其他 return 类型 "searchValue" 的 "RecordRef" 记录也有同样的问题。

This("searchValue.name") 将为空,类似于详细说明的问题 ,但与 CustomFields 不同的是,我没有看到任何基于 [= 检索查找值的记录方式33=] 的 returned "searchValue"(通常填充)。更复杂的是,returned 对象似乎没有指定 "typeId"。它看起来像这样:

所以我又想知道,如何从 SuiteTalk("searchValue.name") 访问我可以从 NetSuite 界面看到的文本值?缺少 NetSuite 文档,在本例中显然是 type "period",但如何枚举它?或者在这种情况下,也许有不同的方法来检索值?

我一直在四处寻找,但关于这方面的文章并不多。我认为 this post. Other than that I really can't find anything. I've already checked the API documentation, here and here, it's not much help, I wonder if there is some sort of internal documentation on the subject that I'm not seeing, but from what I've read there's really, not much.

中提到了这个问题

通过尝试 SuiteTalk 中的所有获取和搜索方法,我找到了似乎是答案的方法,我发现了一个能够返回正确类型结果的方法:

NetSuiteService nsService = ... //Your NetSuiteService
IEnumerable<TransactionSearchRow> rows = ... //The results of your query

var lookup = nsService.getList(rows.
                Where(a => a.basic.postingPeriod.Any())
                .Select(a =>
                {
                    var value = a.basic.postingPeriod[0].searchValue;
                    value.type = RecordType.accountingPeriod;
                    value.typeSpecified = true;
                    return value;
                })
                .GroupBy(a => a.internalId)
                .Select(a => a.First())
                .ToArray()).readResponse
                .ToDictionary(a => ((AccountingPeriod)a.record).internalId, 
                    a => ((AccountingPeriod)a.record).periodName);

var allPeriods = rows
    .Select(a => a.basic.postingPeriod.Any() ? 
         lookup[a.basic.postingPeriod[0].searchValue.internalId] : "")
    .ToArray();

这个方法是listed here,但它并没有真正提供足够的细节。另外,我不确定为什么:

Period(Column) = a.basic.postingPeriod(Property) = RecordType.accountingPeriod(Property) = AccountingPeriod(Type)

我想一种类型也必须猜测每种类型对应的是什么。对于 period 来说还算不错,但是对于其他一些来说可能有点混乱。

我希望这对其他人有所帮助,对我来说这是一个艰难的过程。如果其他人有任何其他解决方案,我仍然愿意接受建议。我仍然不确定这是最有效的数据检索方法。