Node.insertBefore(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Inserts a new child node before an existing child node for the current node.

If the new child node is already in the list of children, this method removes the new child node and inserts it again.

Returns

xml.Node

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/xml Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.newChild

xml.Node

required

The new child node to insert.

options.refChild

xml.Node

required

The node before which to insert the new child node.

If refChild is , the method inserts the new node at the end of the list of children.

Errors

Error Code

Message

Thrown If

SSS_XML_DOM_EXCEPTION

HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.

Node cannot be inserted.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/xml Module Script Samples.

          //Add additional code 
...
var insertednode = parentNode[0].insertBefore({
    newChild : elemlist1[0],
    refChild : elemlist2[0]
});
...
//Add additional code 

        

Related Topics

xml.Node
N/xml Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices