英文:
Suitescript search changing from a var to a function
问题
function invoiceSearchObj() {
/* {N/search.Filter} */
var filters = [];
/* {N/search.Column} */
var columns = [];
var 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 });
}
英文:
I am comfortable with programming searches in Suitescript as a variable. I am trying to convert to a function with "push" capability - but my javascript is failing..
Here is original code:
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"
})
]
});
Here is where I am at with a function:
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});
}
I am getting errors starting with the item.type (tried Kit and Kit/Package) - not sure if this is my coding or the variables I am using..
Thanks in advance!
答案1
得分: 1
你在连接到另一条记录进行筛选时,应该使用连接属性(join property)。
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' }
];
英文:
You should utilize the join property when doing joins to another record for filters.
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' }
];
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论