我对在Suitescript中作为变量的编程搜索很满意。我试图转换为一个函数"push"功能-但我的javascript是失败的…
原代码:
var invoiceSearchObj = search.create({
type: "invoice",
filters:
[
["item.type","anyof","Kit"],
"AND",
["trandate","within","01/01/2023"],
"AND",
["type","anyof","CustInvc"],
"AND",
["item.custitemitemoriginal","is","T"],
"AND",
["status","anyof","CustInvc:B"]
],
columns:
[
search.createColumn({
name: "tranid",
summary: "MAX",
sort: search.Sort.ASC
}),
search.createColumn({
name: "formulatext",
summary: "MAX",
formula: "{item.memberitem}"
}),
search.createColumn({
name: "internalid",
join: "createdFrom",
summary: "MAX"
})
]
});
这里是我在一个函数:
function invoiceSearchObj() {
/* {N/search.Filter} */
var filters = [];
/* {N/search.Column} */
var columns = [];
filterParams =
[
{name: 'item.type', operator: search.Operator.ANYOF, values: 'Kit/Package'},
{name: 'trandate', operator: search.Operator.WITHIN, values: '01/01/2023'},
{name: 'item.custitemitemoriginal', operator: search.Operator.IS, values: 'T'},
{name: 'status', operator: search.Operator.ANYOF, values: 'CustInvc:B'}
];
/* Add each filter to the search */
filterParams.forEach(function(params){
filters.push(search.createFilter(params));
});
columns.push(search.createColumn({name: 'tranid', summary: search.Summary.MAX, sort: search.Sort.ASC}));
columns.push(search.createColumn({name: 'formulatext', summary: search.Summary.MAX, formula: '{item.memberitem}'}));
columns.push(search.createColumn({name: 'internalid', join: 'createdFrom', summary: search.Summary.MAX}));
return search.create({type: search.Type.INVOICE, filters: filters, columns: columns});
}
我从项目开始得到错误。类型(尝试工具包和工具包/包)-不确定这是我的编码还是我使用的变量…提前感谢!
在与另一条记录进行连接时,应该使用join属性。
filterParams =
[
{ name: 'type', join: 'item', operator: search.Operator.ANYOF, values: 'Kit/Package' },
{ name: 'trandate', operator: search.Operator.WITHIN, values: '01/01/2023' },
{ name: 'custitemitemoriginal', join: 'item', operator: search.Operator.IS, values: 'T' },
{ name: 'status', operator: search.Operator.ANYOF, values: 'CustInvc:B' }
];