Node.replaceChild(options)
Method Description |
Replaces a specific child node with another child node in a list of child nodes. If the new child node to add already exists in the list of child nodes, the node is first removed. |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
required |
New child node to add. |
|
|
required |
Child node to replaced with the new node. |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist. |
Child node cannot be found. |
|
HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. |
Child node cannot be replaced. |
Syntax
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 replacednode = parentNode.replaceChild({
newChild : elem[2],
oldChild : elem[1]
});
...
//Add additional code