Hi!
I suppose this question has been answered before, but I am struggling to figure it out myself atm. I changed the mode of a Code node to “Run once for each item” and am getting a “items is not defined” error. This is on n8n cloud.
This is the code:
const { url, title, short_summary, long_summary, websiteTags, type } = JSON.parse(items[0].json.message.content);
const permalink = $node["Slack_get_permalink"].json["permalink"];
const posted_by = $node["Slack_get_user_info"].json.user["real_name"];
const tagsArray = websiteTags.split(',').filter(tag => tag.trim() !== '').map(tag => ({ name: tag.trim() }));
return [
{
json: {
parent: {
type: "database_id",
database_id: "857a90a3a06c442eaeccda241ef88005"
},
properties: {
"Titel": {
title: [
{
text: {
content: title
}
}
]
},
"%5DPYM": { //Zusammenfasung
"type": "rich_text",
"rich_text": [
{
"type": "text",
"text": {
"content": short_summary,
"link": null
},
}
]
},
"dyS%3F": { //URL
"type": "url",
"url": url
},
"KVr%3D": { //Gepostet von
"type": "rich_text",
"rich_text": [
{
"type": "text",
"text": {
"content": posted_by,
"link": null
},
}
]
},
"%40FmA": { //Typ
"type": "select",
"select": {
"name": type,
}
},
"W__w": { //Tags
"type": "multi_select",
"multi_select": tagsArray
},
"I%5CDt": { //Slack URL
"type": "url",
"url": permalink
},
"eVKI": { //Lange Zusammenfasung
"type": "rich_text",
"rich_text": [
{
"type": "text",
"text": {
"content": long_summary,
"link": null
},
}
]
}
}
},
}
];
And this is the input:
[
{
"index": 0,
"message": {
"role": "assistant",
"content": "CONTENT"
},
"finish_reason": "stop"
},
{
"index": 0,
"message": {
"role": "assistant",
"content": "CONTENT"
},
"finish_reason": "stop"
}
]
Any hints as to how to change the code for the new mode? Thanks a lot!