ANS-1491 · SUITESCRIPT DEVELOPMENT
How to Access Record Type and ID in NetSuite XEDIT User Event Scripts?
For SuiteScript 2.0 XEDIT user event scripts, retrieve the record type and ID by accessing the newRecord object.
Short answer
In SuiteScript 2.0 user event scripts of type xedit, context.id and context.recordtype return empty strings. To correctly access the record type and ID, developers must use context.newRecord.id and context.newRecord.recordtype. This method applies specifically to xedit contexts, differing from edit or create operations.
Scenario
When developing SuiteScript 2.0 user event scripts, developers may encounter situations where attempting to retrieve the record ID or type using context.id or context.recordtype within an xedit execution context results in empty strings. This behavior is specific to xedit operations, where the standard context properties do not provide the expected record details.
Solution
In SuiteScript 2.0 user event scripts, when the execution type is xedit (e.g., in beforeSubmit or afterSubmit functions), the standard context.id and context.recordtype properties will return empty strings. To correctly retrieve the record's internal ID and type in an xedit context, developers should access these values through the newRecord object within the context parameter. Use the following properties:
context.newRecord.idcontext.newRecord.recordtypeThis method is specific to xedit operations, differing from edit or create contexts where context.id and context.recordtype typically provide the necessary information directly.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
