Change the value of one field in a list

Hello,

I want to change “Hop Exchange” value for “Hop Protocol”. I’m trying with Set node but it changes for the entire protocol items.

Thanks!

Just add a Function Item node with the following code:

item.Protocol = 'Hop Protocol';
return item;
Example workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "\nitem.Protocol = 'Hop Protocol';\nreturn item;"
      },
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        720,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      \"Protocol\": \"Hop Exchange\" \n    }\n  }\n]"
      },
      "name": "Mockup data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Mockup data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mockup data": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

Thanks! It worked!