# setAttribute()

Esta función se encarga de agregar un nuevo atributo a algún elemento que encuentre almacenado en la variable global "systemElements", ya sean activos (assets), conductores (drivers), etc.

<details class="mb-m" id="bkmrk-body-parametersparam"><summary class="text-muted">Esta función recibe como parámetro un objeto JSON con los siguientes atributos:</summary>

<div></div><div><table class="table" style="height: 222px; width: 619px;" width="811"><tbody><tr style="height: 41px;"><th style="width: 320px; height: 41px;">Atributos</th><th style="width: 301px; height: 41px;">Definición </th></tr><tr style="height: 41px;"><td style="width: 320px; height: 41px;"><div><div>element</div></div></td><td style="width: 301px; height: 41px;">Cadena con la que se definió el elemento a obtener.

</td></tr><tr style="height: 41px;"><td style="width: 320px; height: 41px;"><div><div>key</div></div></td><td style="width: 301px; height: 41px;">Identificador en el cual se puede acceder a la información de los elementos.</td></tr><tr style="height: 58px;"><td style="width: 320px; height: 58px;"><div>attribute</div><div><div></div></div></td><td style="width: 301px; height: 58px;">Nombre del nuevo atributo a agregar en el elemento</td></tr><tr style="height: 41px;"><td style="width: 320px; height: 41px;"><div><div>value</div></div></td><td style="width: 301px; height: 41px;">Valor que sera asignado al atributo</td></tr></tbody></table>

</div></details>Para este ejemplo se agregara un nuevo atributo a un elemento de activos (assets) que se encuentra en la variable "systemElements"<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">.</span>

<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">Ejemplo de solicitud en JS para almacenar conductores:</span>

```JavaScript
try {
        _gpsApiv2.setAttribute({ element: 'assets', key: '0aa30b6cd600c3a3OLD', attribute:'nuevo', value:'atributo' });
 	} catch (error) {
	   console.error(error);
	}
```

<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">Ejemplo de elemento "0aa30b6cd600c3a3OLD" antes de agregar un atributo:</span>

```JavaScript
{
  Address: ""
  Alto_icono: 60
  Ancho_icono: 60
  DatosJson: {datos_extras: {…}}
  Equipo: "0aa30b6cd600c3a3OLD"
  FechaHora: "2022-05-04 17:29:09"
  Icono: "https://plataforma.service24gps.com/commons/svg/3d_camion_caja.php?c=f7f7f7&b=f40b0b&p=235&t=FF3637&f=F39C12"
  IdVehiculo: "138584"
  Latitud: "-15.34409226358717"
  Longitud: "-75.1444648522207"
  Nombre: "0aa30b6cd600c3a3"
  Placa: "0aa30b6cd600c3a3"
  Velocidad: "60"
  lat: "-15.34409226358717"
  lat_lon: "-15.34409226358717,-75.1444648522207"
  lng: "-75.1444648522207"
  marker: _.Ig {__gm: {…}, gm_accessors_: {…}, position: _.Ee, gm_bindings_: {…}, title: '', …}
  [[Prototype]]: Object
}
```

<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">Ejemplo de elemento "0aa30b6cd600c3a3OLD" después de agregar un atributo:</span>

<div data-lang="JavaScript" id="bkmrk-"><div></div></div>```JavaScript
{
  Address: ""
  Alto_icono: 60
  Ancho_icono: 60
  DatosJson: {datos_extras: {…}}
  Equipo: "0aa30b6cd600c3a3OLD"
  FechaHora: "2022-05-04 17:29:09"
  Icono: "https://plataforma.service24gps.com/commons/svg/3d_camion_caja.php?c=f7f7f7&b=f40b0b&p=235&t=FF3637&f=F39C12"
  IdVehiculo: "138584"
  Latitud: "-15.34409226358717"
  Longitud: "-75.1444648522207"
  Nombre: "0aa30b6cd600c3a3"
  Placa: "0aa30b6cd600c3a3"
  Velocidad: "60"
  lat: "-15.34409226358717"
  lat_lon: "-15.34409226358717,-75.1444648522207"
  lng: "-75.1444648522207"
  marker: _.Ig {__gm: {…}, gm_accessors_: {…}, position: _.Ee, gm_bindings_: {…}, title: '', …}
  nuevo: "atributo"
  [[Prototype]]: Object
}
```