# \[SUGGESTION\] add Append to change node

**URL:** <https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375>\
**Category:** Core Development\
**Created:** [17 August 2018 21:15 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375 "2018-08-17T21:15:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [17 August 2018 21:15 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/1 "2018-08-17T21:15:27Z")

</div>

I end up using a (simple) JSONata expression to append text to existing msg.payloads (e.g when sending tweets out)

Is there a none JSONata/JS way of doing this?

If not, how about adding Append as an option in the change node (as well as set,change,move,delete)?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [17 August 2018 21:34 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/2 "2018-08-17T21:34:55Z")

</div>

The trouble is you then start down the slippery slope of all the various operations possible.

If we added append, why not prepend, split, trim, indexOf etc - and that's just for String types. For arrays - push,pop,slice and so on.

That may be something to consider, but it risks throwing too many options in the node.

Someone already has created a node for Strings - [https://flows.nodered.org/node/node-red-contrib-string](https://flows.nodered.org/node/node-red-contrib-string)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [17 August 2018 21:58 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/3 "2018-08-17T21:58:55Z")

</div>

I was only after a LITTLE bit of cream on top........

🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [18 August 2018 08:16 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/4 "2018-08-18T08:16:00Z")

</div>

your right, we'd need prepend as well

but that's all 🙂

> [@knolleary](#):
>
> but it risks throwing too many options in the node.

I'm not normally one for pointing out what happens elsewhere to boost my case but....

...the switch node has a LOT of options 🙂

And I see the change node as its main companion.

The more things that can be achieved by these two nodes without resorting to code or contrib nodes would be good for Node-RED?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [18 August 2018 08:23 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/5 "2018-08-18T08:23:20Z")

</div>

It is worth considering, but not by adding one option at a time.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 August 2018 08:40 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/6 "2018-08-18T08:40:58Z")

</div>

> [@cymplecy](#):
>
> I end up using a (simple) JSONata expression to append text to existing msg.payloads

I tried this. I thought I should be able to use a Change node to Set msg.payload to  
`payload & "extra text"`  
but the JSONata window doesn't like it. Using node-red v0.18.7

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [18 August 2018 08:47 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/7 "2018-08-18T08:47:48Z")

</div>

mm -works for me (in 0.19.1) and it always worked for me in 0.18.7 as well

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4582fff256730cd7bc9659d416abe029359283e8.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 August 2018 08:58 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/8 "2018-08-18T08:58:27Z")

</div>

Sorry, just me being careless, I had JSON instead of J:

So given that it is so easy(!) I can't see that it is worth adding a specific Append option.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [18 August 2018 09:05 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/9 "2018-08-18T09:05:44Z")

</div>

well... I think one of the the main selling points of Node-RED is NOT having to code to achieve simple (or even quite complex) things hence my request 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [18 August 2018 09:09 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/10 "2018-08-18T09:09:04Z")

</div>

JFI - This all came about by me looking thru my change nodes and seeing which ones had JSONata in them and then seeing if I could use @BartButenaers Blocky node instead

And I found that quite a few of them were just using JSONata to prepend/append text/flowContext stuff to a payload

Simon

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [18 August 2018 13:53 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/11 "2018-08-18T13:53:04Z")

</div>

There is a pretty simple way to append (or prepend) using a `change` node with regex:

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

... as long as you know that `^` means "start of string", and `$` means "end of string".

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [18 August 2018 14:09 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/12 "2018-08-18T14:09:58Z")

</div>

🙂

well.......

is using RegEx programming?

Discuss 🙂

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [18 August 2018 15:59 UTC](https://discourse.nodered.org/t/suggestion-add-append-to-change-node/2375/13 "2018-08-18T15:59:07Z")

</div>

> [@cymplecy](#):
>
> Discuss

Let's not
