Preset + auto provision with tags

Hello, Im trying to make a preset that auto provision the CPE if the user reset to factory.

By now, we use a preset on our CPE that come with a preset PPPoE, if the user reset it we can configure remotly but Im starting to work with genieACS to have more possibility.

So, by default it connect via PPPoE, the default PPPoE has limited access to internet and has connection to the ACS as well.

Ive made this script to “store” the PPPoE and ignore the default PPPoE using tags but it wont updating the tag.

"function provision(device, context) {
const defaultPPPoEUsername = “tr069remote”;
const pppoeConnections = device.get(“InternetGatewayDevice.WANDevice..WANConnectionDevice..WANPPPConnection.*”);

if (pppoeConnections && pppoeConnections.length > 0) {
pppoeConnections.forEach((pppoeConnection, index) => {
const pppoeUsername = pppoeConnection.Username;

  if (pppoeUsername && typeof pppoeUsername === "string" && pppoeUsername !== defaultPPPoEUsername) {
    const sanitizedUsername = pppoeUsername.replace(/[^a-zA-Z0-9_-]/g, "_");
    const tagName = `PPPoE_${sanitizedUsername}`;

    // Remove a tag antiga (se existir)
    device.tags.remove(/^PPPoE_/); // Remove todas as tags que começam com "PPPoE_"

    // Adiciona a nova tag
    device.tags.add(tagName);
    context.log(`Tag criada: ${tagName}`);
  } else {
    context.log(`Nome de usuário do PPPoE ignorado (padrão ou inválido): ${pppoeUsername}`);
  }
});

} else {
context.log(“Nenhuma conexão PPPoE encontrada.”);
}
}"

The script is used to update the tag as well if the CPE change ownership.

But this wont working, any help?