Require the 'N/record' module and call record.load({ type: record.Type.SALES_ORDER, id: internalId }) to retrieve an existing record
Read field values with record.getValue({ fieldId: 'entity' }) and set them with record.setValue({ fieldId: 'memo', value: 'updated' })
For sublist lines, call record.selectLine({ sublistId: 'item', line: 0 }) then record.setCurrentSublistValue(...) before record.commitLine(...)
Call record.save() to persist; it returns the record's internal ID
To create a new record use record.create({ type: record.Type.JOURNAL_ENTRY, isDynamic: true }) and then setValue/setSublistValue as above
Wrap operations in try/catch and log errors with N/log to diagnose governance or validation failures
Known gotchas
Dynamic mode (isDynamic: true) and standard mode use different sublist APIs; mixing them on the same record causes runtime errors
record.save() consumes governance units proportional to record complexity; monitor unit usage in scheduled and map/reduce contexts to avoid termination
Loading a record in a beforeLoad user event passes a read-only copy in some contexts — check the script type and entry point before attempting setValue
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp