通过记录搜索加载netsuite中客户的默认地址
Load defaultaddress of customer in netsuite via record search
我正在创建一个 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 脚本的剩余 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
}
知道如何最好地加载客户的默认地址,同时使用分页搜索功能加载所有客户吗?
{defaultaddress}
是在加载客户记录时计算的 - 它不是存储字段,不可用于已保存的搜索。正如字段帮助所说,它只是默认的帐单地址,并会根据您在地址子选项卡中选中“默认帐单”的地址自动更改。
要解决此问题并显示您要查找的内容,您只需将 defaultaddress
替换为 billaddress
。
我正在创建一个 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 脚本的剩余 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
}
知道如何最好地加载客户的默认地址,同时使用分页搜索功能加载所有客户吗?
{defaultaddress}
是在加载客户记录时计算的 - 它不是存储字段,不可用于已保存的搜索。正如字段帮助所说,它只是默认的帐单地址,并会根据您在地址子选项卡中选中“默认帐单”的地址自动更改。
要解决此问题并显示您要查找的内容,您只需将 defaultaddress
替换为 billaddress
。