# Flow.set changes flow name from 01 to 1

**URL:** https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637
**Category:** General
**Tags:** function-node
**Created:** [12 June 2024 09:55 UTC](https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637 "2024-06-12T09:55:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![wcx](https://avatars.discourse-cdn.com/v4/letter/w/3d9bf3/32.png) [@wcx](https://discourse.nodered.org/u/wcx)
#### Post date: [12 June 2024 09:55 UTC](https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637/1 "2024-06-12T09:55:52Z")

</div>

Morning Team.

I have a function node that sets some context values.

For some odd reason if I look at my context flow data the name gets changed from "config\_alarm.alarm.zones.01.state" to "config\_alarm.alarm.zones.1.state"

Example Message

```auto
{"_msgid":"ab716e5b1004ff95",
"payload":"arm",
"topic":"/alarm/zone/arm/normal/01,02,03",
"_event":"node:3e0554c5207a26f4"}

```

```auto
var var_str_zone_reference = msg.topic.substring(msg.topic.lastIndexOf("/") + 1);
node.warn(var_str_zone_reference)

var var_array_zone_reference = var_str_zone_reference.split(",");
node.warn(var_array_zone_reference)

for (var var_str_zone_reference of var_array_zone_reference) {
    node.warn(var_str_zone_reference)

    msg.topic = "config_alarm.alarm.zones." + var_str_zone_reference + ".state";
    node.warn(msg.topic);

    if (msg.payload == "arm" || msg.payload == "disarm"){
        flow.set(msg.topic, msg.payload + "ed");
        flow.set
    }
}
   

```

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [12 June 2024 10:11 UTC](https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637/2 "2024-06-12T10:11:31Z")

</div>

The flow.set() function that writes to context is taking 01 and parsing it as a number 1 and is creating an array in context.  
If you want a object with key 01 then use square bracket notation.  
e.g.

```auto
    msg.topic = "config_alarm.alarm.zones['" + var_str_zone_reference + "'].state";

```

or better still use the best practice form of property names , which should start with a letter or underscore.  
e.g.

```auto
    msg.topic = "config_alarm.alarm.zones._" + var_str_zone_reference + ".state";

```

p.s. Hi and welcome to the forum.

---

<div class="post-metadata">

### Author: ![wcx](https://avatars.discourse-cdn.com/v4/letter/w/3d9bf3/32.png) [@wcx](https://discourse.nodered.org/u/wcx)
#### Post date: [12 June 2024 10:31 UTC](https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637/3 "2024-06-12T10:31:35Z")

</div>

@E1cid, that works thanks so much for the help!!!

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [12 June 2024 11:58 UTC](https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637/4 "2024-06-12T11:58:37Z")

</div>

> [@E1cid](#):
>
> The flow.set() function that writes to context is taking 01 and parsing it as a number 1 and is creating an array in context.  
> ...  
> or better still use the best practice form of property names , which should start with a letter or underscore.

So if flow.set sees an object key which can be converted to a number it does so and you end up with an array?

Is that a feature of the flow.set code, or of Javascript in general?

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [12 June 2024 12:05 UTC](https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637/5 "2024-06-12T12:05:43Z")

</div>

Without looking at the underlying flowset code, i can not say. Seems a bit of a strange behaviour, possible bug? But it is not good practice to use numbers as object keys.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [26 June 2024 12:06 UTC](https://discourse.nodered.org/t/flow-set-changes-flow-name-from-01-to-1/88637/6 "2024-06-26T12:06:18Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
