insertLine Method for Sublist Management in SuiteScript

The insertLine method enables sublist line insertion in SuiteScript, managing line positions dynamically for client and server scripts.

·2 min read·View Oracle Docs

The insertLine method is a powerful feature in SuiteScript that allows developers to dynamically insert a line into a sublist. It is crucial for scenarios where maintaining the correct order of sublist lines is essential, as this method shifts succeeding lines downward and increments the line count accordingly.

Method Overview

The insertLine method is used to insert a line into a specified sublist of a NetSuite record. This manipulation is essential for both client and server scripts where dynamic management of record details is required.

Returns

The method returns a record.Record object that represents the updated record.

Supported Script Types

  • Client scripts
  • Server scripts

Parameters

The insertLine method takes an options parameter, which is a JavaScript object containing the following fields:

ParameterTypeRequired / OptionalDescription
options.sublistIdstringRequiredThe internal ID of the sublist to which you are adding a line. This can be viewed in the Records Browser.
options.linenumberRequiredThe line number at which to insert the new line, starting from 0.
options.ignoreRecalcbooleanOptionalIf set to true, it ignores recalculation. The default is false.

Handling Errors

Developers should be aware of possible errors that may be thrown when using this method:

  • SSS_INVALID_SUBLIST_OPERATION: This error occurs if a required argument is invalid or if the sublist is not editable.
  • SSS_MISSING_REQD_ARGUMENT: This error indicates that a required argument is either missing or undefined.

Syntax Example

Here's how to use the insertLine method:

suitescript
1// Adding a line to the attendee sublist
2objRecord.insertLine({
3 sublistId: 'attendee',
4 line: 2,
5});
6objRecord.setCurrentSublistValue({
7 sublistId: 'attendee',
8 fieldId: 'attendee',
9 value: 838
10});
11objRecord.commitLine({
12 sublistId: 'attendee'
13});

Remember, this code is a simple syntax demonstration and should be integrated within a larger functional script for actual implementation.

Who This Affects

  • Developers: Particularly those working on client and server scripts within SuiteScript.
  • Administrators: Managing custom scripts that involve sublist manipulations.

Key Takeaways

  • The insertLine method is essential for managing sublists in SuiteScript, accommodating real-time data manipulation.
  • Understanding parameter requirements is crucial for error-free implementation.
  • This method supports both client and server script types, enhancing flexibility in custom script development.

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?
Yes, the insertLine method supports both client and server scripts, allowing dynamic management of sublist lines in various types of SuiteScript.
What happens if the sublist is not editable when using insertLine?
If the sublist is not editable, using the insertLine method will throw an SSS_INVALID_SUBLIST_OPERATION error, indicating that the operation is invalid.
Is it necessary to specify the options.ignoreRecalc parameter when using insertLine?
The options.ignoreRecalc parameter is not required. It is optional and defaults to false. If set to true, it ignores recalculation after the line insertion.
What error is thrown if a necessary argument is missing when using insertLine?
An SSS_MISSING_REQD_ARGUMENT error is thrown if a required argument such as sublistId or line is missing or undefined when using the insertLine method.
Source: Parameters 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 SuiteScript

View all SuiteScript articles →