# VirtualParameter does not edit

**URL:** <https://forum.genieacs.com/t/virtualparameter-does-not-edit/605>\
**Category:** Uncategorized\
**Created:** [February 13, 2020, 1:56am UTC](https://forum.genieacs.com/t/virtualparameter-does-not-edit/605 "2020-02-13T01:56:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxthetor](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxthetor](https://forum.genieacs.com/u/maxthetor)\
**Post date:** [February 13, 2020, 1:56am UTC](https://forum.genieacs.com/t/virtualparameter-does-not-edit/605/1 "2020-02-13T01:56:19Z")

</div>

I created a virtualparameter taking username from pppoe from two different brands of routers.  
It’s working ok.  
But when I edit the user does not change the router. There is no error.  
The username parameter I can edit normal.

* * *

criei um virtualparameter pegando username do pppoe de duas marcas diferentes de roteadores.  
Esta funcionando ok.  
Mas quando eu edito o usuario nao modifica no roteador. Nao apresenta nenhum erro.  
O parametro username eu consigo editar normal.

-----------------------------------script--------------------------------------------------

let m = “”;  
if (args[1].value) {  
m = args[1].value[0];  
declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.2.Username”, null, {value: m});  
declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.3.WANPPPConnection.1.Username”, null,{value: m});  
}  
else {  
let d = declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.2.Username”, {value: Date.now()});  
let igd = declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.3.WANPPPConnection.1.Username”, {value: Date.now()});  
if (d.size) {  
m = d.value[0];  
}  
else if (igd.size) {  
m = igd.value[0];  
}  
}  
return {writable: true, value: [m, “xsd:string”]};

* * *

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [February 13, 2020, 5:47pm UTC](https://forum.genieacs.com/t/virtualparameter-does-not-edit/605/2 "2020-02-13T17:47:02Z")

</div>

Try this:

```javascript
let username = "";
if ("value" in args[1]) {
    // Set declared value
    username = args[1].value;
    declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username", null, {value: username});
} else {
    let igd = declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username", {value: 1});

    if (igd.size) {
        for (let p of igd) {
            if (p.value[0]) {
                username = p.value[0];
                break;
            }
        }
    }
}
return {writable: true, value: [username, "xsd:string"]};

```

---

<div class="post-metadata">

**Author:** ![maxthetor](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxthetor](https://forum.genieacs.com/u/maxthetor)\
**Post date:** [February 14, 2020, 1:19am UTC](https://forum.genieacs.com/t/virtualparameter-does-not-edit/605/3 "2020-02-14T01:19:35Z")

</div>

thanks for the feedback.

with this function i am getting the following errors in tasks.

too\_many\_commits “faultMessage =” Too many commit iterations "

I tried to change the function to:

username = args [1] .value [0];

so the tasks do not return an error, but did not change the parameter on the router.

---

<div class="post-metadata">

**Author:** ![maxthetor](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@maxthetor](https://forum.genieacs.com/u/maxthetor)\
**Post date:** [February 16, 2020, 1:46am UTC](https://forum.genieacs.com/t/virtualparameter-does-not-edit/605/4 "2020-02-16T01:46:52Z")

</div>

my version: 1.2.0-beta.0+20191111024633
