I am trying to call the Netsuite SuiteScript 2.0 N/record
module's load function, but I am unsure as to what to pass for the parameters. Basically I would like a N/record
with the same id (primary key) of the current record in the UI, that I can use to loop through the sublist items.
I'm not sure how to use the Records Browser in order to find the correct type and id. The Records Browser does not have the type, so I guessed at the name. There are also multiple fields that could be the primary key id. Is it tranid
or externalid
or some other field? I'm specifically interested in the Inventory Adjustment form. externalid
is undefined and tranid
is To Be Generated.
Is it possible to get a N/Record
based on the currentRecord
in this manner or will it also suffer from the same issues I have with currentRecord
(I can't use selectLine
to step through the sublist items, sublist items have not been saved yet and the last one is partially completed)?
/**
* @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
});