Element.setAttribute(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Adds a new attribute with the specified name. If an attribute with that name is already present in the element, its value is changed to the value specified in method argument.

If an attribute with the specified name already exists, the value of the attribute is changed to the value of the value parameter.

Returns

void

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.name

string

required

Name of the attribute to add.

options.value

string

required

Value of the attribute to add.

Errors

Error Code

Message

Thrown If

SSS_XML_DOM_EXCEPTION

INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.

Value for the attribute cannot be set.

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 
...
elem[0].setAttribute({
    name : 'lang',
    value : 'fr'
});
...
//Add additional code 

        

Related Topics

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

General Notices