Concatenate string

Describe the problem/error/question

Well, i’m not very demanding… I just want to concatenate strings…

text = “a”

then i want text = “ab”

then i want texte = “abc”

Can’t figure the correct way to do this…

Please share your workflow

Information on your n8n setup

  • n8n version: current

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @presta_melt

You are crabbing the original text everytime, that of course doesn’t do what you want to do here.
Try grabbing the text like this:

{{$json.text}}

And then add whatever you want after it. like

{{$json.text}}bc

1 Like

ty :slight_smile:

Correct version :point_down:

or

1 Like

Hi @presta_melt

Yeah that is it.

Just a small note it comes across ungrateful if you mark your own answer as the solution. :wink:

2 Likes

sorry, didn’t know that

But for real business cases, as soon, as i add some other nodes (for example xml conversions, but that’s true for everything), it doesn’t work anymore…

Correct. Because you don’t have such properties in the Convert nodes. You’ll need to refer the node before them.

Oh yes, it’s like moving a variable each time.

Isn’t it possible to keep the same variable from start to finish?

N8n is not like programming, so there is often not the need for a variable type object to keep changing.
Have you done the courses? They might give you a better understandig on how to do it with n8n.
Your original question had you refering to specific nodes and fields.
My answer was how to do it in a flow.
You might need a combination of that or use merge nodes to combine and then modify data.
Ps. I personally always use merge nodes for things like this, as it makes sure no funky business happens.

Except for settings or single values coming into a flow. Only then I use references to other nodes.

Ok, I understand, I was reasoning as in a programming language…

What I’m trying to do is build a chain composed of different elements, one after the other…

If element 1 is not empty, create element 1 via API, fetch data from the API for element 1, and add it to the chain.

If element 2 is not empty, create element 2 via API, fetch data from the API for element 2, and add it to the chain.

And at the end, retrieve the chain for further processing.

I’ll take a look at the merge node!

Yeah so whenever you are having multiple lines going into a node you need to think to your self if you need a merge node.
Sometimes it is fine, but most of the time you want to combine the data and you need to use a merge for that.
It of course always depends. :slight_smile:

Usually if the WF has repetitive parts, they can be replaced with a sub workflow, which will be called for each similar part in a Loop

1 Like

Thanks everybody for your answers.

I didn’t manage to use merge (i have 12 values to merge)…

So I managed to do it with code, even if i understand that it’s not the best thing to do…

I know i’m new to n8n, but 2 days to build a string from various API output, wow… I feel disapointed !

Will go on and keep upgrading my knowledge anyway ! :upside_down_face: :

ps i don’t know if (and where) i should mark this thread solution…