N/record
📚 Module 3, 5, 6record.create(options)
record.create({ type: record.Type.CUSTOMER, isDynamic: true })
Creates a new record in memory. Use isDynamic: true for sublist operations.
record.load(options)
record.load({ type: record.Type.SALES_ORDER, id: 123, isDynamic: true })
Loads an existing record from the database.
record.save(options)
var id = myRecord.save({ enableSourcing: true })
Saves record to database. Returns internal ID.
record.submitFields(options)
record.submitFields({ type: 'customer', id: 123, values: { comments: 'Updated' } })
Updates fields without loading record. Much more efficient!
▶ Show Example
// Much better than load() + setValue() + save()!
record.submitFields({
type: record.Type.CUSTOMER,
id: 12345,
values: { 'comments': 'Updated via script' },
options: { ignoreMandatoryFields: true }
});
record.delete(options)
record.delete({ type: record.Type.CUSTOMER, id: 123 })
Deletes a record. Cannot be undone!
record.copy(options)
record.copy({ type: record.Type.SALES_ORDER, id: 123 })
Creates a copy of an existing record (not saved).
record.getValue(options)
var value = myRecord.getValue({ fieldId: 'entity' })
Gets internal value of a field. For list fields, returns ID.
record.getText(options)
var text = myRecord.getText({ fieldId: 'entity' })
Gets display text of a field. For list fields, returns name.
record.setValue(options)
myRecord.setValue({ fieldId: 'memo', value: 'Updated' })
Sets value of a body field.
record.getLineCount(options)
var count = myRecord.getLineCount({ sublistId: 'item' })
Returns number of lines in a sublist.
record.getSublistValue(options)
var qty = rec.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: 0 })
Gets value from a sublist line. Line is 0-based.
record.setSublistValue(options)
rec.setSublistValue({ sublistId: 'item', fieldId: 'quantity', line: 0, value: 5 })
Sets value on a sublist line (standard mode).
record.selectNewLine(options)
myRecord.selectNewLine({ sublistId: 'item' })
Selects new line for editing (dynamic mode).
record.setCurrentSublistValue(options)
rec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: 123 })
Sets value on current line (dynamic mode).
record.commitLine(options)
myRecord.commitLine({ sublistId: 'item' })
Commits current line to sublist (dynamic mode).
record.attach(options)
record.attach({ record: { type: 'file', id: 123 }, to: { type: 'customer', id: 456 } })
Attaches a record (like file) to another record.
N/search
📚 Module 7search.create(options)
search.create({ type: 'customer', filters: [...], columns: [...] })
Creates a new search. Must run() to get results.
▶ Show Example
var customerSearch = search.create({
type: search.Type.CUSTOMER,
filters: [
['isinactive', 'is', 'F'],
'AND',
['balance', 'greaterthan', 0]
],
columns: ['entityid', 'email', 'balance']
});
customerSearch.run().each(function(result) {
log.debug('Customer', result.getValue('entityid'));
return true;
});
search.load(options)
search.load({ id: 'customsearch_my_search' })
Loads an existing saved search by script ID.
search.lookupFields(options)
search.lookupFields({ type: 'customer', id: 123, columns: ['email'] })
Gets fields from single record. Very efficient!
▶ Show Example
var fields = search.lookupFields({
type: search.Type.CUSTOMER,
id: 12345,
columns: ['email', 'phone', 'salesrep']
});
log.debug('Email', fields.email);
log.debug('Sales Rep', fields.salesrep[0].text);
search.run().each()
mySearch.run().each(function(result) { return true; })
Runs search, iterates up to 4000 results.
search.runPaged(options)
mySearch.runPaged({ pageSize: 1000 })
For 4000+ results. Returns PagedData.
resultSet.getRange(options)
mySearch.run().getRange({ start: 0, end: 100 })
Gets specific range of results. Max 1000.
search.createColumn(options)
search.createColumn({ name: 'amount', summary: search.Summary.SUM })
Creates column for search. Supports joins, summaries.
search.createFilter(options)
search.createFilter({ name: 'status', operator: 'anyof', values: ['A'] })
Creates filter for search.
N/runtime
📚 Module 10runtime.getCurrentScript()
var script = runtime.getCurrentScript()
Returns current script object for parameters, governance.
runtime.getCurrentUser()
var user = runtime.getCurrentUser()
Returns current user with id, name, email, role.
script.getRemainingUsage()
var remaining = runtime.getCurrentScript().getRemainingUsage()
Returns remaining governance units.
script.getParameter(options)
script.getParameter({ name: 'custscript_my_param' })
Gets script parameter value from deployment.
N/email
📚 Module 5email.send(options)
email.send({ author: 123, recipients: 456, subject: 'Hi', body: '...' })
Sends email. Author must be employee ID.
▶ Show Example
email.send({
author: 123,
recipients: ['customer@example.com', 456],
cc: [789],
subject: 'Your Order',
body: '<html><body>Thank you!</body></html>',
relatedRecords: { transactionId: orderId }
});
email.sendBulk(options)
email.sendBulk({ author: 123, recipients: [...], subject: '...', body: '...' })
Sends bulk emails. Counts against daily limits.
N/file
📚 Module 5file.create(options)
file.create({ name: 'report.txt', fileType: file.Type.PLAINTEXT, contents: '...' })
Creates new file in memory. Call save() to store.
file.load(options)
file.load({ id: 123 })
Loads file from File Cabinet.
file.getContents()
var contents = myFile.getContents()
Returns file contents as string.
N/url
📚 Module 12url.resolveScript(options)
url.resolveScript({ scriptId: '...', deploymentId: '...', params: {...} })
Generates URL to Suitelet/RESTlet. Use returnExternalUrl: true for external.
url.resolveRecord(options)
url.resolveRecord({ recordType: 'customer', recordId: 123 })
Generates URL to a NetSuite record.
N/redirect
📚 Module 12redirect.toRecord(options)
redirect.toRecord({ type: 'salesorder', id: 123 })
Redirects user to a record.
redirect.toSuitelet(options)
redirect.toSuitelet({ scriptId: '...', deploymentId: '...', parameters: {...} })
Redirects user to a Suitelet.
N/render
📚 Module 12render.create()
var renderer = render.create()
Creates TemplateRenderer for PDF generation.
renderer.renderAsPdf()
var pdfFile = renderer.renderAsPdf()
Renders template as PDF file.
renderer.addRecord(options)
renderer.addRecord({ templateName: 'record', record: myRecord })
Adds record to renderer for template variables.
N/format
📚 Module 5format.parse(options)
format.parse({ value: '12/31/2024', type: format.Type.DATE })
Parses string to native type (Date, Number).
format.format(options)
format.format({ value: new Date(), type: format.Type.DATETIME })
Formats value to string for display.
N/task
📚 Module 8task.create(options)
task.create({ taskType: task.TaskType.SCHEDULED_SCRIPT, scriptId: '...' })
Creates task to schedule script execution.
▶ Show Example
var scriptTask = task.create({
taskType: task.TaskType.SCHEDULED_SCRIPT,
scriptId: 'customscript_my_scheduled',
deploymentId: 'customdeploy_my_scheduled',
params: { 'custscript_last_id': lastProcessedId }
});
var taskId = scriptTask.submit();
task.submit()
var taskId = myTask.submit()
Submits task for execution. Returns task ID.
N/log
📚 Module 2log.debug(title, details)
log.debug('My Title', JSON.stringify(obj))
Debug message. Only shows at Debug log level.
log.audit(title, details)
log.audit('Record Saved', 'ID: ' + id)
Audit message. For significant production events.
log.error(title, details)
log.error('Error', e.message + ' | ' + e.stack)
Error message. Shows in red. Use in catch blocks.
log.emergency(title, details)
log.emergency('CRITICAL', 'System failure')
Emergency message. Highest priority level.
N/ui/serverWidget
📚 Module 12serverWidget.createForm(options)
serverWidget.createForm({ title: 'My Form' })
Creates form for Suitelets.
form.addField(options)
form.addField({ id: 'custpage_myfield', type: serverWidget.FieldType.TEXT, label: 'My Field' })
Adds field to form. ID must start with 'custpage_'.
form.addButton(options)
form.addButton({ id: 'custpage_btn', label: 'Click', functionName: 'myFunc()' })
Adds button to form. functionName is client JS.
form.addSubmitButton(options)
form.addSubmitButton({ label: 'Submit' })
Adds submit button that POSTs form.
form.addSublist(options)
form.addSublist({ id: 'custpage_items', type: serverWidget.SublistType.LIST, label: 'Items' })
Adds sublist/table to form.
response.writePage(form)
context.response.writePage(form)
Writes form to response (displays page).
📚 Complete SuiteScript 2.x Module Reference
All available N/ modules with descriptions and documentation links.
N/action
Execute record actions that emulate UI buttons. Load to trigger workflow actions or custom actions on records.
N/auth
Change NetSuite login credentials programmatically.
N/cache
Cache data to improve script performance. Store frequently accessed data to reduce API calls.
N/certificateControl
Access digital certificates for signing documents and secure communications.
N/commerce
Access web store assets like items, cart, and customer data in SuiteCommerce context.
N/compress
Compress, decompress, and archive files (ZIP, GZIP).
N/config
Access NetSuite configuration settings and company preferences.
N/crypto
Hashing, HMAC, and symmetrical encryption using OpenSSL wrappers.
N/crypto/certificate
Sign XML documents with digital certificates using asymmetric cryptography.
N/crypto/random
Cryptographically-secure pseudo-random number generation.
N/currency
Work with exchange rates between currencies based on specific dates.
N/currentRecord
Access the current record instance in client scripts. Auto-loaded in entry point scripts.
N/dataset
Create and manage datasets in SuiteAnalytics Workbook.
N/documentCapture
Extract text content from documents (invoices, receipts, contracts) using AI.
N/email
Send regular, bulk, and campaign emails from within NetSuite.
N/encode
Convert strings between different character encodings (Base64, UTF-8, etc.).
N/error
Create custom SuiteScript errors for try-catch statements.
N/file
Work with files in NetSuite File Cabinet - create, read, upload, download.
N/format
Convert strings to/from formatted data (dates, numbers, currency, phone).
N/format/i18n
Format currency with international locale settings.
N/http
Make HTTP requests to external services.
N/https
Make HTTPS requests. Encode binary content and access credential fields securely.
N/https/clientCertificate
Send SSL requests with mutual TLS using digital certificates.
N/keyControl
Access key storage for secrets and credentials.
N/llm
Use generative AI / large language models (LLMs) in scripts.
N/log
Log script execution details for debugging and auditing.
N/machineTranslation
Translate text into supported languages using generative AI.
N/pgp
Send PGP-encrypted secure messages to recipients.
N/piremoval
Remove personal information from system notes, workflow history, and fields (GDPR).
N/plugin
Load custom plug-in implementations for extensibility.
N/portlet
Resize or refresh form portlets on dashboards.
N/query
Create and run searches using SuiteQL (SQL-like syntax) via SuiteAnalytics Workbook.
N/record
Work with NetSuite records - create, load, save, delete, copy, transform.
N/recordContext
Get the context type of a record (how it was accessed).
N/redirect
Redirect users to URLs, Suitelets, records, task links, or searches.
N/render
Create PDFs, forms from templates, and emails from templates. Print functionality.
N/runtime
Access runtime settings for company, script, session, user, and version info.
N/scriptTypes/restlet
Create custom request/response handling for RESTlet scripts.
N/search
Create and run saved searches. lookupFields, create, load, run, iterate results.
N/sftp
Connect to remote FTP servers using SFTP and transfer files.
N/suiteAppInfo
Access information about installed SuiteApps and Bundles.
N/task
Create and queue tasks: scheduled scripts, Map/Reduce, CSV imports, workflow execution.
N/task/accounting/recognition
Merge revenue arrangements or revenue elements for revenue recognition.
N/transaction
Void transactions programmatically.
N/translation
Load Translation Collections for multi-language support.
N/ui/dialog
Create modal dialogs with buttons (alert, confirm, create).
N/ui/message
Display messages at the top of the screen under the menu bar.
N/ui/serverWidget
Build custom UIs - forms, fields, buttons, sublists for Suitelets and User Events.
N/url
Build URLs for records, Suitelets, task links. Resolve domain paths.
N/util
Utility methods: isArray, isObject, isFunction, each, extend.
N/workbook
Create and manage workbooks in SuiteAnalytics Workbook (charts, pivots, tables).
N/workflow
Initiate new workflow instances or trigger existing ones programmatically.
N/xml
Validate, parse, read, and modify XML documents. XPath support.