要查询特定记录:您需要在 Netsuite 中创建/部署一个 RESTlet,类似于以下内容:
/**
* @NApiVersion 2.1
* @NScriptType Restlet
*/
define([
"N/log",
"N/search",
], function (log, search) {
function post(context) {
return JSON.stringify(getCustomRecords(context));
}
function getCustomRecords(context) {
log.debug('POST Context', context);
return search.lookupFields({
//Change CUSTOM_RECORD to the type of custom record you are querying
type: search.Type.CUSTOM_RECORD + '1589',
id: context.id,
columns: context.fields,
});
}
return {
post: post,
};
});
在您的 Python 脚本中:确保将请求的 URL 更改为这个新 RESTlet 的部署 URL。此外,请确保在您的 POST 请求有效负载中传递您需要的任何参数(例如我的示例中的“id”或“字段”)。所以而不是:
payload = {
"name":"value",
"foo":"bar",
"duck":"hunt",
}
通过
payload = {
"id":"9999999",
"fields": ["custrecord_field1", "custrecord_field2"],
}
其中 id 是您要查询的记录的 internalid,fields 数组是您要从中获取值的字段的 internalid。
如果成功,结果应该在你的 python 脚本中显示为 conn.text!