NetSuite SuiteScript 2 - 通过搜索访问子列表
NetSuite SuiteScript 2 - Access sublist via Search
我正在搜索给定日期范围内的客户付款,我需要获取已为每笔客户付款支付的发票的发票参考号。发票参考号位于子列表 apply
下,其中字段 apply
设置为 true。
我会放一些code/payload:
search.create({
type: search.Type.CUSTOMER_PAYMENT,
filters: [['lastmodifieddate', 'within', context.from_datetime, context.to_datetime]],
columns: [
'entity',
'status',
]
}).run().forEach(function(result) {
// Do stuff
});
这是客户支付负载的(简短版本):
{
"id": "103",
"type": "customerpayment",
"isDynamic": false,
"fields": {
// payment main fields
},
"sublists": {
// Other sublists
"apply": {
"line 1": {
"apply": "T",
"currency": "GBP",
"refnum": "TEST-00002",
// Other fields
},
"line 2": {
"apply": "F",
"currency": "GBP",
"refnum": "TEST-00001",
// Other fields
}
}
}
因此,在搜索列数组中,我想从 apply
字段为 T 的行项目中获取 refnum
字段。(在这种情况下应该 return TEST -00002)
抓取整个应用子列表就足够了,然后我将计算出循环到对象中的引用句柄。
我想避免的是每次都加载付款记录,因为它会减慢搜索速度。
这可能吗?任何人都可以帮忙吗?
非常感谢!
我相信您要查找的是应用到事务字段。您可以在列表底部的 UI 中以连接的形式访问它们,也可以通过如下所示的 SuiteScript 访问它们。在我的帐户中,refnum 字段与 Applied To 交易的文档编号相同,因此我可以通过以下方式获取编号:
var customerpaymentSearchObj = search.create({
type: "customerpayment",
filters:
[
["type","anyof","CustPymt"],
],
columns:
[
"tranid",
"entity",
"amount",
"appliedtotransaction",
"appliedtolinkamount",
"appliedtolinktype",
search.createColumn({
name: "tranid",
join: "appliedToTransaction"
}) // <--- This is the one
]
});
customerpaymentSearchObj.run().each(function(result){
// .run().each has a limit of 4,000 results
var refnum = result.getValue({ name: 'tranid', join: 'appliedToTransaction' });
return true;
});
我正在搜索给定日期范围内的客户付款,我需要获取已为每笔客户付款支付的发票的发票参考号。发票参考号位于子列表 apply
下,其中字段 apply
设置为 true。
我会放一些code/payload:
search.create({
type: search.Type.CUSTOMER_PAYMENT,
filters: [['lastmodifieddate', 'within', context.from_datetime, context.to_datetime]],
columns: [
'entity',
'status',
]
}).run().forEach(function(result) {
// Do stuff
});
这是客户支付负载的(简短版本):
{
"id": "103",
"type": "customerpayment",
"isDynamic": false,
"fields": {
// payment main fields
},
"sublists": {
// Other sublists
"apply": {
"line 1": {
"apply": "T",
"currency": "GBP",
"refnum": "TEST-00002",
// Other fields
},
"line 2": {
"apply": "F",
"currency": "GBP",
"refnum": "TEST-00001",
// Other fields
}
}
}
因此,在搜索列数组中,我想从 apply
字段为 T 的行项目中获取 refnum
字段。(在这种情况下应该 return TEST -00002)
抓取整个应用子列表就足够了,然后我将计算出循环到对象中的引用句柄。
我想避免的是每次都加载付款记录,因为它会减慢搜索速度。
这可能吗?任何人都可以帮忙吗? 非常感谢!
我相信您要查找的是应用到事务字段。您可以在列表底部的 UI 中以连接的形式访问它们,也可以通过如下所示的 SuiteScript 访问它们。在我的帐户中,refnum 字段与 Applied To 交易的文档编号相同,因此我可以通过以下方式获取编号:
var customerpaymentSearchObj = search.create({
type: "customerpayment",
filters:
[
["type","anyof","CustPymt"],
],
columns:
[
"tranid",
"entity",
"amount",
"appliedtotransaction",
"appliedtolinkamount",
"appliedtolinktype",
search.createColumn({
name: "tranid",
join: "appliedToTransaction"
}) // <--- This is the one
]
});
customerpaymentSearchObj.run().each(function(result){
// .run().each has a limit of 4,000 results
var refnum = result.getValue({ name: 'tranid', join: 'appliedToTransaction' });
return true;
});