# Change node, modify message property

**URL:** <https://discourse.nodered.org/t/change-node-modify-message-property/38127>\
**Category:** General\
**Created:** [28 December 2020 09:06 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127 "2020-12-28T09:06:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 December 2020 09:06 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/1 "2020-12-28T09:06:22Z")

</div>

I know I have asked before, but can't remember the exact wording.

Only to save using nodes, I want to change a message property in a change node.

So what I want to do:

I am getting `msg.delay` and multiply it by 1000.

I know I have to enter it in the `J:` expression part, but.... That's the limit.

I'll try a could of things, but I know the system is if I don't ask I won't remember.  
If I do ask, before I get an answer the probability of me remembering will go up.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 December 2020 09:08 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/2 "2020-12-28T09:08:53Z")

</div>

Remembered:

`msg.delay = msg.delay * 1000`

Couldn't really be easier.

---

<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:** [28 December 2020 12:37 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/3 "2020-12-28T12:37:08Z")

</div>

> [@Trying\_to\_learn](#):
>
> msg.delay = msg.delay \* 1000

Please explain how the above expression is the solution to modifying msg.delay in a change node?

Using that expression in a change node will modify the property value to `false`, it will not multiply it by 1000.

Use `delay * 1000` in the JSONata expression.

What you posted will work in a function node, but your question was for a change node. I had to say something as your solution may confuse others looking for a solution to modifying in a change node.

```auto
[{"id":"b95ccd5.63ef1b","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"delay","v":"4","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":1940,"wires":[["70ea60b1.134808"]]},{"id":"70ea60b1.134808","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"delay * 1000","tot":"jsonata"},{"t":"set","p":"delay","pt":"msg","to":"msg.delay = msg.delay * 1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":1940,"wires":[["be48273.628c958"]]},{"id":"be48273.628c958","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":1940,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 December 2020 12:47 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/4 "2020-12-28T12:47:24Z")

</div>

In fairness, Andrew did say...

> [@Trying\_to\_learn](#):
>
> I know I have to enter it in the `J:` expression part

---

<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:** [28 December 2020 12:54 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/5 "2020-12-28T12:54:54Z")

</div>

I fail to see your point. Entering a Javascript expression into a JSONata expression box still will not work, and the solution is confusing to other users.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 December 2020 13:11 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/6 "2020-12-28T13:11:45Z")

</div>

Sorry, yes, you are right, I am assuming (since he said it works) that he didnt _actually_ put `msg.delay = msg.delay * 1000` into the expression (as it wouldnt work). I read this as he set `msg.delay` to `msg.delay * 1000` using `J:` expression.

but yes, you are right to clarify - it is a bit unclear for those not reading between the lines.

---

<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:** [28 December 2020 13:13 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/7 "2020-12-28T13:13:35Z")

</div>

To clarify `msg.delay * 1000`will not work either.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 December 2020 13:16 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/8 "2020-12-28T13:16:12Z")

</div>

It does.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/fff390b2531bf49639cec65bd51e91f1f6e642d0.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2d7efed960e14fcfea785e661a35a5007d679b34.png)

```auto
[{"id":"e71f4e83.15362","type":"inject","z":"f77cda4d.5d7628","name":"delay: 2","props":[{"p":"payload"},{"p":"delay","v":"2","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1190,"y":260,"wires":[["464da612.cf3418"]]},{"id":"464da612.cf3418","type":"change","z":"f77cda4d.5d7628","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"msg.delay * 1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":300,"wires":[["ff13eed3.37ddd"]]},{"id":"ff13eed3.37ddd","type":"debug","z":"f77cda4d.5d7628","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1230,"y":340,"wires":[]}]

```

---

<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:** [28 December 2020 13:19 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/9 "2020-12-28T13:19:18Z")

</div>

Apology, It does indeed work. I never use msg in JSONata as it is not needed.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 December 2020 13:20 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/10 "2020-12-28T13:20:20Z")

</div>

> [@E1cid](#):
>
> I never use msg in JSONata as it is not needed

No its not, but if memory serves, it is there for backwards compatibility.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 December 2020 20:22 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/11 "2020-12-28T20:22:08Z")

</div>

Wow.... Ok.

I am using the `change` node and I needed to change things.

This is the part of the flow in question:

```auto
[{"id":"7f22aa5b.695bbc","type":"ui_slider","z":"ae12fd.00ef75","name":"Sydney","label":"Frequency (m)","tooltip":"","group":"ebcaab30.c904b","order":2,"width":3,"height":1,"passthru":false,"outs":"end","topic":"","min":"1","max":"30","step":1,"x":420,"y":3820,"wires":[["4acbf31d.4b45b4"]]},{"id":"4acbf31d.4b45b4","type":"change","z":"ae12fd.00ef75","name":"convert to minutes","rules":[{"t":"move","p":"payload","pt":"msg","to":"delay","tot":"msg"},{"t":"set","p":"delay","pt":"msg","to":"msg.delay * 60000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":525,"y":3820,"wires":[["110b9f17.9c9241"]],"l":false},{"id":"110b9f17.9c9241","type":"trigger","z":"ae12fd.00ef75","name":"Variable","op1":"trigger","op2":"0","op1type":"str","op2type":"str","duration":"-30","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":630,"y":3820,"wires":[["f57d4697.23dda"]]},{"id":"ebcaab30.c904b","type":"ui_group","name":"Sydney weather","tab":"de0f6b36.132fa8","order":2,"disp":true,"width":"8","collapse":false},{"id":"de0f6b36.132fa8","type":"ui_tab","name":"Weather","icon":"dashboard","order":17,"disabled":false,"hidden":false}]

```

The `slider` node outputs `msg.payload` and I need it to be `msg.delay` to adjust the delay time on the `trigger` node.

But I don't want to send numbers that big to control the delay/repeat time from 1 minute to 30 minutes.

So, the `change` node moves `msg.payload` to `msg.delay`. (Line 1)  
(Line 2) multiplies `msg.delay` by 60000 to make the number for minutes.

---

<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:** [11 January 2021 20:22 UTC](https://discourse.nodered.org/t/change-node-modify-message-property/38127/12 "2021-01-11T20:22:13Z")

</div>

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