[SUGGESTION] add Append to change node

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)?

1 Like

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

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

:slight_smile:

your right, we'd need prepend as well

but that's all :slight_smile:

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

...the switch node has a LOT of options :slight_smile:

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?

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

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

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

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.

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 :slight_smile:

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

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

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

4 Likes

:slight_smile:

well.......

is using RegEx programming?

Discuss :slight_smile:

2 Likes

Let's not

2 Likes