Describe the problem/error/question
After the upgrade to version 1, I have some broken workflows that used Function nodes. I’m changing them to code nodes for better forward compatibility but it seems then when using
$input.last().json.item.length to calculate the length of item arrays, I’m getting an undefined error. Is the .length method no longer usable in new versions or is there a change with the code node I’m not aware of? Thanks in advance.
What is the error message (if any)?
ERROR: Cannot read properties of undefined (reading ‘length’) [line 2]
Please share your workflow
Information on your n8n setup
n8n version: 1.5.1
n8n EXECUTIONS_PROCESS setting (default: own, main): Default
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
Operating system: Ubuntu 22.04.3 LTS
Welcome to the community
.json.item what is the value of
item? It could also be worth trying
.length() but I suspect the issue is that the input may not have a field called item.
Hi @Jon ,
Thanks a lot for the welcome. I double checked after your reply and realized that the code node works a bit differently from the function / function item nodes now. The single code node has an “Execute once for all items” or “Execute once for each time” mode and based on the mode you select, data input arrives either as items.json.items or item.json.item. There is no longer items.json.item as was previously done in the function node.
Problem solved! Thanks for your help and the hint
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.