[GSHEET] - Updating a Value in Google sheet

Hello, I getting a trouble to find if I’m missing something to performa update on record with update in google sheet. Follow bellow my workflow.

On my Set node the field “Sit Pag” will change this value, and I want this changes on the same record in other sheet.

Anything could help me to handle this.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        420,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "id",
              "value": "234"
            },
            {
              "name": "Nome",
              "value": "Rodrigo Correia"
            },
            {
              "name": "Sit Pag",
              "value": "Pago"
            },
            {
              "name": "Data",
              "value": "={{new Date().toLocaleString()}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        570,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [],
          "number": [
            {
              "value1": "={{Object.values($json).length}}",
              "operation": "larger"
            }
          ]
        }
      },
      "name": "find_unique",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1170,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Code here will run only once, no matter how many input items there are.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function\n\n// Loop over inputs and add a new field called 'myNewField' to the JSON of each one\nlet values = $items('append_data');\nconsole.log(values);\n\n\nreturn values;"
      },
      "name": "Function2",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1350,
        420
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "={{$node[\"append_data\"].parameter[\"sheetId\"]}}",
        "range": "={{$node[\"find_fatura_id\"].parameter[\"range\"]}}",
        "options": {
          "valueInputMode": "USER_ENTERED"
        }
      },
      "name": "insert_data",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        1570,
        420
      ],
      "credentials": {
        "googleApi": "Google Sheet API"
      }
    },
    {
      "parameters": {
        "operation": "update",
        "sheetId": "={{$node[\"append_data\"].parameter[\"sheetId\"]}}",
        "range": "={{$node[\"find_fatura_id\"].parameter[\"range\"]}}",
        "options": {
          "valueInputMode": "USER_ENTERED"
        }
      },
      "name": "update_value",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        1600,
        230
      ],
      "credentials": {
        "googleApi": "Google Sheet API"
      }
    },
    {
      "parameters": {
        "functionCode": "// Code here will run only once, no matter how many input items there are.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function\n\n// Loop over inputs and add a new field called 'myNewField' to the JSON of each one\nlet values = $items('append_data');\nconsole.log(values);\n\n\nreturn values;"
      },
      "name": "Function3",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1350,
        230
      ]
    },
    {
      "parameters": {
        "operation": "lookup",
        "sheetId": "={{$node[\"append_data\"].parameter[\"sheetId\"]}}",
        "range": "unique!A:D",
        "lookupColumn": "id",
        "lookupValue": "={{$json[\"id\"]}}",
        "options": {}
      },
      "name": "find_fatura_id",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        980,
        300
      ],
      "alwaysOutputData": true,
      "credentials": {
        "googleApi": "Google Sheet API"
      }
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "1Zqhjf2xxo0LawqjfumuoHq7UAcarvV7N2Ii2iAm9sUE",
        "range": "all!A1:D",
        "options": {}
      },
      "name": "append_data",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        770,
        300
      ],
      "credentials": {
        "googleApi": "Google Sheet API"
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "append_data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "find_unique": {
      "main": [
        [
          {
            "node": "Function3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Function2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function2": {
      "main": [
        [
          {
            "node": "insert_data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function3": {
      "main": [
        [
          {
            "node": "update_value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "find_fatura_id": {
      "main": [
        [
          {
            "node": "find_unique",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "append_data": {
      "main": [
        [
          {
            "node": "find_fatura_id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@RicardoE105 don’t you have any tip to give in this question? You help me a lot in other questions.

Hi @rodrigoscdc, hope you are having a good Friday? Have you had a look at this example workflow from @harshil1712 which updates a specific row based on a given key value and can adapt this one to your needs?

I had a look but did not fully understand what you wanted to do. Can you please elaborate? Also, can you share the columns of the spreadsheets you are working with?

1 Like

Hey @rodrigoscdc,

I just wanted to check in and see if you still need help :slight_smile:

Hello Guys thanks for your reply what was happening is that my key field was a string and node was number, after a I changed the type of value to the same it works.

2 Likes