Challenge When I Need to Update Task

Describe the problem/error/question

after i created my work flow i need to update the Clickup task with the last value but it seem that the click up step cannot able to catch the id from the Trigger or from the 2nd step that already cath all information for the task

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
{
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "1ed5f1cd01b00d5b3875f281848e031e26825790b1f3ffc6803c26378e4cd4db"
  },
  "nodes": [
    {
      "parameters": {
        "operation": "get",
        "id": "={{ $json.task_id }}"
      },
      "id": "72e785cd-041f-4ce4-b82f-773f95931410",
      "name": "data",
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        1060,
        420
      ],
      "credentials": {
        "clickUpApi": {
          "id": "5RbPez7s1xbeQ7XH",
          "name": "Squadio-Account"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "custom_fields",
        "options": {}
      },
      "id": "0a2036cf-9abb-4155-9f88-763c3a5f9f06",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1280,
        420
      ]
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\ndata =[]\n\nfor (const item of $input.all()) {\n\n  item_data = {\n              name : item.json.name,\n              value : parseInt(item.json.value),\n            }\n  if (item.json.name == \"Attendance\" || \n     item.json.name  == \"Time Tracker\"  ||\n     item.json.name  == \"Utilization (PM)\"  ||\n     item.json.name  == \"Raised Issues\"||\n     item.json.name  == \"Squadio Rating (Compliance)\"  ||\n     item.json.name  == \"Quality - Supervisor\" ||\n     item.json.name   ==\"Quality - Tech Assessment\"\n     ) {                    \n     data.push(item_data);\n  }\n  \n \n}\n\n\n\nreturn (data)"
      },
      "id": "46dfc926-dae6-4c3c-9fb7-775fe71efbce",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1500,
        420
      ]
    },
    {
      "parameters": {
        "fieldsToSummarize": {
          "values": [
            {
              "aggregation": "average",
              "field": "value"
            }
          ]
        },
        "options": {}
      },
      "id": "86f34d47-dcfb-4fca-aa18-7f9f6c8cb185",
      "name": "Summarize",
      "type": "n8n-nodes-base.summarize",
      "typeVersion": 1,
      "position": [
        1720,
        420
      ]
    },
    {
      "parameters": {
        "operation": "setCustomField",
        "task": "={{ $('Trigger').item.json.task_id }}",
        "field": "3c8a6c8c-d5e4-41ca-a069-1552411a8059",
        "value": "={{ $json.average_value }}"
      },
      "id": "c7e5f91b-5c62-4924-8113-64759847bf36",
      "name": "ClickUp",
      "type": "n8n-nodes-base.clickUp",
      "typeVersion": 1,
      "position": [
        1940,
        420
      ],
      "credentials": {
        "clickUpApi": {
          "id": "5RbPez7s1xbeQ7XH",
          "name": "Squadio-Account"
        }
      }
    },
    {
      "parameters": {
        "team": "2153872",
        "events": [
          "taskUpdated"
        ],
        "filters": {
          "listId": "901502705928",
          "spaceId": "55369263"
        }
      },
      "id": "c0454da2-8ddb-412d-b553-ccde655ae2f2",
      "name": "Trigger",
      "type": "n8n-nodes-base.clickUpTrigger",
      "typeVersion": 1,
      "position": [
        840,
        420
      ],
      "webhookId": "2668267a-a136-436b-92ee-53d6d754fade",
      "credentials": {
        "clickUpApi": {
          "id": "5RbPez7s1xbeQ7XH",
          "name": "Squadio-Account"
        }
      }
    }
  ],
  "connections": {
    "data": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Summarize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize": {
      "main": [
        [
          {
            "node": "ClickUp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger": {
      "main": [
        [
          {
            "node": "data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.27.2
  • Database (default: postgress):**
  • n8n EXECUTIONS_PROCESS setting (default: own, main):**
  • Running n8n via (Docker):**
  • Operating system:windows 10

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

i already added it

hello @fahmawy

You can’t refer to the item property as you have some splits and join of items during the excution. For your case, you will need to use the {{ $('Trigger').last().json.task_id }} (or .first(), it doesn’t matter).

And a quick advice of how to check for multiple names in the fancy way :slight_smile:

data =[]

for (const item of $input.all()) {
  const allowedNames = [
    "Attendance",
    "Time Tracker",
    "Utilization (PM)",
    "Raised Issues",
    "Squadio Rating (Compliance)",
    "Quality - Supervisor",
    "Quality - Tech Assessment",
  ]
  
  item_data = {
              name : item.json.name,
              value : parseInt(item.json.value),
            }
  if (allowedNames.includes(item.json.name)) {                    
     data.push(item_data);
  }
  
 
}



return data
2 Likes

Thanks for your reply, now it works fine <3 and I will consider that ISA

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.