[SUGGESTION] add Append to change node

#1

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

0 Likes

#2

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

0 Likes

#3

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

:slight_smile:

0 Likes

#4

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?

0 Likes

#5

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

0 Likes

#6

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

0 Likes

#7

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

0 Likes

#8

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.

0 Likes

#9

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:

0 Likes

#10

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

0 Likes

#11

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

#12

:slight_smile:

well.......

is using RegEx programming?

Discuss :slight_smile:

2 Likes

#13

Let's not

2 Likes