The most fundamental concept to master in SuiteScript is working with NetSuite’s Record objects. Records are the interface of the NetSuite database. With SuiteScript 2.0, we use the N/record Module and N/currentRecord Module to script with records.
Load the record module to work with NetSuite records. You can use this module to create, delete, copy, load, or make changes to a record.
The Record Modules (2.0) allows us to manipulate record objects within the NetSuite. It encapsulates a large number of record manipulation functions and objects from SuiteScript 1.0:
nlapiLoadRecord
nlapiCreateRecord
nlapiSubmitRecord
nlapiCopyRecord
nlapiTransformRecord
nlapiDeleteRecord
nlapiAttachRecord
nlapiSubmitRecord
nlobjRecord
I just want to highlight some of them here to understand the fundamental behind this.
Suitescript 1.0 Function/Object | Suitescript 2.0 Equivalent | Return Type |
---|---|---|
nlapiLoadRecord | r.load (options) | r.Record |
nlapiCreateRecord | r.create (options) | r.Record |
nlobjRecord.getFieldValue | r.Record.getValue | Same field type |
nlobjRecord.setFieldValue | r.Record.setValue | Void |
nlapiDeleteRecord | r.delete (options) | Number |
nlapiSubmitRecord | r.Record.save (options) | Number |
nlobjRecord | r.Record | NA |
Note:The nlobjRecord Object type has also been translated to the Record Object type within the N/record module, and it contains similar get and set methods to its 1.0 counterpart.
2.0 functions accept a single Object parameter, which is typically named options in the Help documentation.
Load and create both return instances of r.Record, and the save method lives on the Record instance
In client scripts:
- Use N/currentRecord Module methods to interact with the record that is active in the current client-side context.
- Use the N/record Module to load and interact with remote records.
N/record Example
define([“N/record”], function (r) { … });
Entirely based on the concept of ‘modules’, SuiteScript 2.0 renders the capability to structure and organize code into small, meaningful individual units that one can combine together to form more powerful applications. Furthermore, connecting with an acclaimed service provider partner like inoday.us enables a business organization perform faster with this enhanced version.
Will continue to write more on the next article, where we will describe this in more detail.
Find Your NetSuite Expert By Dropping An Email To info@inoday.com