Injecting Javascript functions as data to execute in another node or workflow

When making sub-workflows, I wanted to make them quite “generic”, eg. “Write these records to the database”. But sometimes I need some custom code executed, usually to transform or mutate some data before it gets written. But passing a function wasn’t working - we only can pass data down the line, not functions.

So to solve this, I transform my function into a string, and then execute it later. My example is pretty close to what I use it for - a map - but you could use this logic in a lot of other ways.

2 Likes