The N/currentRecord module gives Client Scripts direct access to the record currently open in the browser β without needing to load it by ID. It is the go-to module for interactive UI scripting in NetSuite forms.
Getting the Current Record
define(["N/currentRecord"], (currentRecord) => {
const fieldChanged = (context) => {
const rec = currentRecord.get();
const val = rec.getValue({ fieldId: "companyname" });
log.debug("Company", val);
};
return { fieldChanged };
});
Setting Field Values
const rec = currentRecord.get();
rec.setValue({ fieldId: "memo", value: "Auto-populated by script" });
const lineCount = rec.getLineCount({ sublistId: "item" });
log.debug("Lines", lineCount);
Available in Client Scripts Only
The N/currentRecord module is exclusively for Client Scripts. For server-side record access, use N/record with the record ID.