Welcome to the forum @SergeantPup
First point, for the future, please see this post for details of how to post flows and code, currently your flow is not importable (but I don't need to import it anyway yet). How to share code or flow json
Most errors that appear in the debug pane will have the name of the node in the first line. Also if you click on that line it should take you to the node generating the error.
The most important information you have provided is the error message in the message you have posted. If you look in there you will see that one of the values that appears in the SQL is just the text undefined
. That is what the database is complaining about. If you add a debug node showing what is going into the node that generates the query and another showing what is coming out of that node then that may give you a better idea of what is going on. I imagine that the data going into the function is missing one field.
If you cannot see why the function is failing then post the debug output of what is going in and out and just the code in that function so we can help with determining the problem.