How do you deal with repetitive tasks in a workflow

For example I am getting input from a form that includes first and last name. I want to do something very simple like if the whole name is in lowercase then capitalise the 1st letter. This would be great as a function but the way I see it I have to make it a single line operation in the fields.
How do you deal with this?

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:

If you have a lot of things you want to change via JavaScript you can pass the output to a Code node (which can actually be Python, too) and operate on all the inputs there, and then return the altered output items. Depending on your workflow and how you like to organize things you could possibly have that be a bit more organized, instead of ad-hoc JS expressions throughout a bunch of node fields.

Sometimes there’s also built-in nodes (the data transformation ones, summarize/etc) that do some types of simple transformations so you can avoid code/expression based mutators entirely and keep it to more visual/node based flows - I think that starts to come down to personal preference and comfort/desire to use code within your workflows though!

I’d be interested to hear if others have any tricks for this too though, sort of like modules/libraries of functionality that can be reused within or throughout workflows.

1 Like

Good morning,

Yes, you will need to use expressions to fix this. There are community nodes that give you a bit more options for text transformation though.

if you have things like this that need to be done many times, you can simply copy paste the node you are using. (set/edit field) or create a subflow where you have these transformations and them call this subflow when needed.

Can also create a code node that deals with it, but that would make it less nice for others that do not know how to write code.

It sounds like these sub flows are the only way to share some code across different workflows
but they also sound quite big and clunky, will they use a lot more resources compared to a simple code node? I’ll have to have a look at it

Shouldnt be too bad. As they are all ran on the main process. of course a bit of overhead but shouldnt be a big deal. Also resources used in subflows will be released after it was completed so it can be good for performance if you are dealing with a lot of data and transformations.

1 Like