Data Manipulation in NetSuite with SuiteScript
Core Data Manipulation Functions:
- CRUD Operations: SuiteScript empowers you to perform the fundamental CRUD (Create, Read, Update, Delete) operations on various NetSuite records. Let’s explore some key functions for each:
- Create: The record.create()function allows you to create new records in NetSuite. You can specify the record type (e.g., customer, sales order) and set field values for the new record.
- Read: The record.load()function retrieves existing records from NetSuite. You can use the record ID or search criteria to locate the desired record and access its field values.
- Update: The record.save()function updates existing records in NetSuite. You can modify specific fields of a loaded record and then usesave()to persist the changes.
- Delete: The record.delete()function permanently removes records from NetSuite. Utilize this function with caution, as deleted data cannot be easily recovered.
Beyond the Basics:
- Field-Level Operations: SuiteScript functions provide granular control over individual fields within records. Functions like record.getFieldValue()allow you to retrieve specific field values, whilerecord.setFieldValue()enables updating those values.
- Searching and Filtering: For efficient data retrieval, SuiteScript offers functions like record.loadSearch()andsearch.createColumn()to define search criteria and filter results based on specific field values.
- Relationships and Lookups: NetSuite data often involves relationships between records. SuiteScript functions like record.getSublistValue()help you access and manipulate data within sublists representing these relationships.