Toggl time entry ID having trouble with Remove Duplicates node

Describe the problem/error/question

I’m trying to, from one side, get my latest time entries in Toggle. And on the other side the latest pages (past time entries) that were added to my Notion database.

For then to compare which time entries are already logged in my Notion database to discard them and avoid creating duplicates in the latter.

The problem is that I’m not sure what I’m doing wrong or what nodes should I use. Below you can see the alternatives i’ve used, but each have their own problems. The one that seems to be ideal for this is “Remove duplicates”. However whenever it tries to get the “id” from the Toggl time entry it says “(The number ID) field is missing from some input items”.

What is the error message (if any)?

{
“errorMessage”: “‘3499007641’ field is missing from some input items”,
“errorDetails”: {},
“n8nDetails”: {
“nodeName”: “Remove Duplicates”,
“nodeType”: “n8n-nodes-base.removeDuplicates”,
“nodeVersion”: 1,
“time”: “23/6/2024, 05:03:49”,
“n8nVersion”: “1.45.1 (Self Hosted)”,
“binaryDataMode”: “default”,
“stackTrace”: [
“NodeOperationError: ‘3499007641’ field is missing from some input items”,
" at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Transform/RemoveDuplicates/RemoveDuplicates.node.js:188:27)“,
" at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:728:42)”,
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:664:66",
" at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1079:20"
]
}
}

Please share your workflow

Share the output returned by the last node

[
{
“id”: 3499007641,
“workspace_id”: 6874852,
“project_id”: 187505202,
“task_id”: null,
“billable”: false,
“start”: “2024-06-23T06:16:38+00:00”,
“stop”: “2024-06-23T07:16:40+00:00”,
“duration”: 3602,
“description”: “XXXXXXXX”,
“tags”: ,
“tag_ids”: ,
“duronly”: true,
“at”: “2024-06-23T06:16:54+00:00”,
“server_deleted_at”: null,
“user_id”: 8979694,
“uid”: 8979694,
“wid”: 6874852,
“pid”: 187505202,
“permissions”: null
},
]

Information on your n8n setup

  • n8n version: 1.45.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): I don’t know
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Windows 10

@Cristobal_Alarcon , The Remove Duplicates nodes is misused in your workflow. It expects the names of the fields in the incoming data but you provide the values of the fields.

As for the solution, you can try to use a similar strategy to the one I recommended in this post. The suggestion is to use Merge nodes to determine which entries exist and which do not. In your case, however, you might need to make sure that the range of items taken from Notion is greater that that from Toggle.

In your case, however, you might need to make sure that the range of items taken from Notion is greater that that from Toggle.

Really? Why?

Ok, I’ve tested it but none of the results match. It’s like instead of looking for a match it’s comparing them in the order they are listed.

Like this:

Toggl Notion Toggl (intended use) Notion (intended use)
Time entry A (New) Logged time entry B Time entry A (New) Create new page
Time entry B Logged time entry C Time entry B Logged time entry B
Time entry C Logged time entry E Time entry C Logged time entry C
Time entry D (New) Logged time entry F Time entry D (New) Create new page
Time entry E Logged time entry G Time entry E Logged time entry E

Right now it’s comparing the Id values directly in how they are ordered instead of finding their matching pages. What can I do about this?

EDIT: After some more testing my Notion node it’s not even getting the pages in the order they should be :frowning. Ok I solved the sorting, but all pages are still being added even if in node merge Inputs 1 and 2 have matching values, with “Keep non-matches” toggled. And the issue I explain with the table persists. This is the updated workflow.

@Cristobal_Alarcon , you did not set up the Merge node the intended way. You are making the same mistake as with the Remove Duplicates node. You have to put the names of the fields that you want to compare but you use the values instead.

That is, the Input 1 Filed should have just id (instead of {{ $node["Get existing time entries Toggl"].json["id"] }}) and Input 2 Field should be just property_id_p_gina (instead of {{ $node["Get existing pages Notion"].json["property_id_p_gina"] }}).

In your case, however, you might need to make sure that the range of items taken from Notion is greater that that from Toggle.

Really? Why?

I used the word “might”. It depends on what criteria is used by both services to return the last items and what discrepancies currently exist between the systems. Otherwise you might end up crating duplicate records in Notion.

2 Likes

Yaay! it works! Finally I won’t have to put up with duplicates after almost two years of using this workflow hahah. Thank you so much!

I used the word “might”. It depends on what criteria is used by both services to return the last items and what discrepancies currently exist between the systems. Otherwise you might end up crating duplicate records in Notion.

To prevent this I could just change the amount of pages the initial Notion node gets to a higher amount?

Yes, exactly.

1 Like

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