我正在创建一个RESTlet来加载分页的客户记录。我需要的一件事是客户的defaultaddress
。当我这样加载单个客户时,此字段可用:
customer = record.load({
type: record.Type.CUSTOMER,
id: context.id, // e.g. 1234
isDynamic: false
});
但是,当我尝试像这样向所有客户加载分页时:
define(['N/record', 'N/search'], function(record, search) {
var currencies = {};
function getClients(context) {
var mySearch = search.create({
type: search.Type.CUSTOMER,
columns: [
{ name: 'companyname' },
{ name: 'vatregnumber' },
{ name: 'lastmodifieddate' },
{ name: 'currency' },
{ name: 'email' },
{ name: 'phone' },
{ name: 'defaultaddress' }
]
});
var searchResult = mySearch.run().getRange({
start: context.start || 0,
end: context.end || 100
});
var results = [];
for (var i = 0; i < searchResult.length; i++) {
results.push({
tax_number: searchResult[i].getValue({ name: 'vatregnumber' }),
name: searchResult[i].getValue({ name: 'companyname' }),
// snipped...
});
}
return results;
}
function loadCurrencyName(id) {
return record.load({
type: record.Type.CURRENCY,
id: id,
isDynamic: false
}).name;
}
return {
get: getClients
}
});
并执行对上述RESETlet脚本的rest api调用;我收到以下错误:
{
"type":"error.SuiteScriptError",
"name":"SSS_INVALID_SRCH_COL",
"message":"An nlobjSearchColumn contains an invalid column, or is not in proper syntax: defaultaddress.",
"stack":[ ... snipped ... ],
"cause":{ ... snipped ... },
"id":"",
"notifyOff":false
}
有什么想法如何最好地加载客户的默认地址,同时使用分页搜索功能加载所有客户?
答案 0 :(得分:2)
{defaultaddress}
是在加载客户记录时计算的-它不是存储的字段,因此无法用于保存的搜索。正如字段帮助所述,它只是默认的帐单地址,并会根据您选中“默认帐单”的地址子选项卡中的地址自动更改。
要解决此问题并显示所需内容,只需将defaultaddress
替换为billaddress
。