Netsuite SuiteScript 2.0 如何完成N/record加载函数的参数
Netsuite SuiteScript 2.0 How to complete the parameters of the N/record load function
我正在尝试调用 Netsuite SuiteScript 2.0 N/record
模块的加载函数,但我不确定要为参数传递什么。基本上我想要一个 N/record
与 UI 中的当前记录具有相同的 id(主键),我可以用它来遍历子列表项。
我不确定如何使用记录浏览器来找到正确的类型和 ID。记录浏览器没有类型,所以我猜到了这个名字。还有多个字段可以作为主键 ID。是 tranid
或 externalid
还是其他字段?我对库存调整表特别感兴趣。 externalid
未定义,tranid
待生成。
是否有可能以这种方式获得基于 currentRecord
的 N/Record
,或者它是否也会遇到与 currentRecord
相同的问题(我无法使用selectLine
逐步遍历子列表项,子列表项尚未保存,最后一个已部分完成)?
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/search', 'N/record'], function (s, r) {
function fieldChanged(context) {
var currentRecord = context.currentRecord;
var sublistName = context.sublistId;
var sublistFieldName = context.fieldId;
var currentLine = context.line;
var recordId = currentRecord.getValue({fieldId: "externalid"});
var record = r.load({
type: r.Type.INVENTORY_ADJUSTMENT,
id: recordId,
isDynamic: true
});
Is it possible to get a N/Record based on the currentRecord
是的,尽管 N/record
模块用于 load/create 记录。所以为了使用 N/record
模块,你需要确保你的记录已经存在或者你正在创建新的。
在 Records Browser 页面顶部指定的 InternalId 是您需要作为 type
传递给 record module
的 recordType。
也尝试使用记录加载的异步版本。即客户端脚本中的 record.load.promise
。
我正在尝试调用 Netsuite SuiteScript 2.0 N/record
模块的加载函数,但我不确定要为参数传递什么。基本上我想要一个 N/record
与 UI 中的当前记录具有相同的 id(主键),我可以用它来遍历子列表项。
我不确定如何使用记录浏览器来找到正确的类型和 ID。记录浏览器没有类型,所以我猜到了这个名字。还有多个字段可以作为主键 ID。是 tranid
或 externalid
还是其他字段?我对库存调整表特别感兴趣。 externalid
未定义,tranid
待生成。
是否有可能以这种方式获得基于 currentRecord
的 N/Record
,或者它是否也会遇到与 currentRecord
相同的问题(我无法使用selectLine
逐步遍历子列表项,子列表项尚未保存,最后一个已部分完成)?
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/search', 'N/record'], function (s, r) {
function fieldChanged(context) {
var currentRecord = context.currentRecord;
var sublistName = context.sublistId;
var sublistFieldName = context.fieldId;
var currentLine = context.line;
var recordId = currentRecord.getValue({fieldId: "externalid"});
var record = r.load({
type: r.Type.INVENTORY_ADJUSTMENT,
id: recordId,
isDynamic: true
});
Is it possible to get a N/Record based on the currentRecord
是的,尽管 N/record
模块用于 load/create 记录。所以为了使用 N/record
模块,你需要确保你的记录已经存在或者你正在创建新的。
在 Records Browser 页面顶部指定的 InternalId 是您需要作为 type
传递给 record module
的 recordType。
也尝试使用记录加载的异步版本。即客户端脚本中的 record.load.promise
。