Insert Line Method in SuiteScript for Sublists
The insertLine method allows for dynamic management of sublists in SuiteScript, ensuring lines can be correctly added.
The insertLine method is a powerful function in SuiteScript that allows developers to insert a new line into a sublist of a record dynamically. This action automatically shifts existing lines downward, effectively updating the line count for the sublist.
Method Description
When you use the insertLine method, it obviates the need for manual adjustments in line numbering, as all subsequent lines are repositioned to accommodate the new entry. This is available in both dynamic and standard modes — for more on this, refer to SuiteScript 2.x Standard and Dynamic Modes.
Returns
The method returns a record.Record object that encapsulates the NetSuite record being manipulated.
Supported Script Types
The insertLine function is applicable in both client and server scripts. For detailed information on script types, see SuiteScript 2.x Script Types.
Governance
The insertLine method does not incur any governance restrictions, allowing for unrestricted use without impacting your script governance budget.
Module
This method is part of the N/record Module.
Parameters
The following table outlines the parameters accepted by the insertLine method:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.sublistId | string | Required | The internal ID of the sublist. Available in the Records Browser. |
options.line | number | Required | The line number for insertion (note: indexing begins at 0). |
options.ignoreRecalc | boolean | Optional | If true, ignores scripting recalculations; defaults to false. |
Errors
It is crucial to handle potential errors when using this method:
SSS_INVALID_SUBLIST_OPERATION: This error is raised if a required argument is invalid or if the sublist is not editable.SSS_MISSING_REQD_ARGUMENT: This error occurs when a required argument is either missing or undefined.
Syntax
Below is a code snippet illustrating the syntax for using the insertLine method. This example is not fully functional but serves to demonstrate the correct usage.
1// Add additional code2...3objRecord.insertLine({4 sublistId: 'attendee',5 line: 2,6});7objRecord.setCurrentSublistValue({8 sublistId: 'attendee',9 fieldId: 'attendee',10 value: 83811});12objRecord.commitLine({13 sublistId: 'attendee'14});15...16// Add additional codeRelated Topics
- record.Record
- N/record Module
- SuiteScript 2.x Modules
- For additional examples involving
N/recordmethods, see N/record Module Script Samples.
Key Takeaways:
- The
insertLinemethod adds lines to sublists effortlessly. - It is applicable in both client and server scripts, with no governance limitations.
- It provides dynamic and standard mode compatibility, ensuring flexibility in scripting.
- Understanding the parameters and potential errors is critical for effective scripting.
Frequently Asked Questions (4)
Can the insertLine method be used in both client and server scripts in NetSuite?
Are there any governance restrictions when using the insertLine method in SuiteScript?
What are the required parameters for using the insertLine method in SuiteScript?
What happens if an invalid sublist is specified when using the insertLine method?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
