Insert Line Method in SuiteScript for Sublists

The insertLine method allows for dynamic management of sublists in SuiteScript, ensuring lines can be correctly added.

·2 min read·View Oracle Docs

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:

ParameterTypeRequired / OptionalDescription
options.sublistIdstringRequiredThe internal ID of the sublist. Available in the Records Browser.
options.linenumberRequiredThe line number for insertion (note: indexing begins at 0).
options.ignoreRecalcbooleanOptionalIf 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.

suitescript
1// Add additional code
2...
3objRecord.insertLine({
4 sublistId: 'attendee',
5 line: 2,
6});
7objRecord.setCurrentSublistValue({
8 sublistId: 'attendee',
9 fieldId: 'attendee',
10 value: 838
11});
12objRecord.commitLine({
13 sublistId: 'attendee'
14});
15...
16// Add additional code

Related Topics

  • record.Record
  • N/record Module
  • SuiteScript 2.x Modules
  • For additional examples involving N/record methods, see N/record Module Script Samples.

Key Takeaways:

  • The insertLine method 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.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

Can the insertLine method be used in both client and server scripts in NetSuite?
Yes, the insertLine method is applicable in both client and server scripts.
Are there any governance restrictions when using the insertLine method in SuiteScript?
No, the insertLine method does not incur any governance restrictions, allowing unrestricted use without impacting your script governance budget.
What are the required parameters for using the insertLine method in SuiteScript?
The required parameters for the insertLine method are options.sublistId (the internal ID of the sublist) and options.line (the line number at which to insert). Optionally, options.ignoreRecalc can be used to ignore script recalculations.
What happens if an invalid sublist is specified when using the insertLine method?
If an invalid sublist is specified, the method will raise an SSS_INVALID_SUBLIST_OPERATION error, indicating the sublist is either invalid or not editable.
Source: Errors Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →