IF block does not compare as expected

Describe the issue/error/question

I’m trying to filter cards i have retrieved from my nextcloud deck app (API description)*. I want to filter cards, that have been modified today (and send a notification to my matrix chat room on which cards have been modified - not implemented yet).

I’m using the IF block and i am trying to compare the lastModified property with the variable value i have created previously. Somehow, the comparison does not work as expected. I get 14 cards of 15 on the true port - i’m expecting one card, as i have modified only one card today. I have decoded the timestamps and they seem to be correct. In the GetDateTimeBlock, i am retreiving the current date as a number and divide it by 1000 to match the datetime number in the lastModified property of the cards.

  • yes, i know, that there is theoretically the possibility to filter items by using the header “If-Modified-Since”. But using this header returns an exception from the nextcloud server.

What is the error message (if any)?

No errors, the node just returns to much (or not expected) data.

Please share the workflow

Share the output returned by the last node

This is the “unfiltered” data i am returning from GetFlatCardList

[
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 140,
      "type": "plain",
      "lastModified": 1631902889,
      "lastEditor": null,
      "createdAt": 1631902873,
      "labels": [
        {
          "title": "dummy title",
          "color": "7C31CC",
          "boardId": 4711
          "cardId": 289,
          "lastModified": 1631616355,
          "id": 175,
          "ETag": "dummy-etag-hash-value"
        }
      ],
      "assignedUsers": [
        {
          "id": 101,
          "participant": {
            "primaryKey": "DummyUser",
            "uid": "DummyUser",
            "displayName": "DummyUser",
            "type": 0
          },
          "cardId": 289,
          "type": 0
        }
      ],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 1000,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 289,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 140,
      "type": "plain",
      "lastModified": 1636200885,
      "lastEditor": null,
      "createdAt": 1636200653,
      "labels": [],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 1,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 1001,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 315,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 141,
      "type": "plain",
      "lastModified": 1640852351,
      "lastEditor": null,
      "createdAt": 1639512666,
      "labels": [
        {
          "title": "dummy title",
          "color": "7C31CC",
          "boardId": 4711
          "cardId": 335,
          "lastModified": 1631616355,
          "id": 175,
          "ETag": "52c8d115870bc9737f4761ed06acea17"
        }
      ],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 1,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 335,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 141,
      "type": "plain",
      "lastModified": 1640852370,
      "lastEditor": null,
      "createdAt": 1639681728,
      "labels": [],
      "assignedUsers": [
        {
          "id": 107,
          "participant": {
            "primaryKey": "DummyUser",
            "uid": "DummyUser",
            "displayName": "DummyUser",
            "type": 0
          },
          "cardId": 336,
          "type": 0
        }
      ],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 2,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 336,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 141,
      "type": "plain",
      "lastModified": 1640852376,
      "lastEditor": null,
      "createdAt": 1639464252,
      "labels": [],
      "assignedUsers": [
        {
          "id": 108,
          "participant": {
            "primaryKey": "DummyUser",
            "uid": "DummyUser",
            "displayName": "DummyUser",
            "type": 0
          },
          "cardId": 333,
          "type": 0
        }
      ],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 3,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 333,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 141,
      "type": "plain",
      "lastModified": 1641151951,
      "lastEditor": null,
      "createdAt": 1641151951,
      "labels": [],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 4,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 346,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 142,
      "type": "plain",
      "lastModified": 1641224823,
      "lastEditor": null,
      "createdAt": 1638392145,
      "labels": [],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 1,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 326,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 143,
      "type": "plain",
      "lastModified": 1641225017,
      "lastEditor": null,
      "createdAt": 1639741900,
      "labels": [],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 0,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 337,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 143,
      "type": "plain",
      "lastModified": 1641226015,
      "lastEditor": null,
      "createdAt": 1639510075,
      "labels": [
        {
          "title": "dummy title",
          "color": "7C31CC",
          "boardId": 4711
          "cardId": 334,
          "lastModified": 1631616355,
          "id": 175,
          "ETag": "52c8d115870bc9737f4761ed06acea17"
        }
      ],
      "assignedUsers": [
        {
          "id": 109,
          "participant": {
            "primaryKey": "DummyUser",
            "uid": "DummyUser",
            "displayName": "DummyUser",
            "type": 0
          },
          "cardId": 334,
          "type": 0
        }
      ],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 1,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 334,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 143,
      "type": "plain",
      "lastModified": 1641225017,
      "lastEditor": null,
      "createdAt": 1636572010,
      "labels": [],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 2,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 318,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 144,
      "type": "plain",
      "lastModified": 1640852382,
      "lastEditor": null,
      "createdAt": 1638905169,
      "labels": [
        {
          "title": "dummy title",
          "color": "7C31CC",
          "boardId": 4711
          "cardId": 328,
          "lastModified": 1631616355,
          "id": 175,
          "ETag": "52c8d115870bc9737f4761ed06acea17"
        }
      ],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 3,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 328,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 144,
      "type": "plain",
      "lastModified": 1640852382,
      "lastEditor": null,
      "createdAt": 1638392155,
      "labels": [],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 4,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 327,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 144,
      "type": "plain",
      "lastModified": 1640852382,
      "lastEditor": null,
      "createdAt": 1639464226,
      "labels": [],
      "assignedUsers": [],
      "attachments": null,
      "attachmentCount": 0,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 5,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 332,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  },
  {
    "card": {
      "title": "dummy title",
      "description": "",
      "stackId": 144,
      "type": "plain",
      "lastModified": 1640852382,
      "lastEditor": null,
      "createdAt": 1630530193,
      "labels": [],
      "assignedUsers": [
        {
          "id": 100,
          "participant": {
            "primaryKey": "DummyUser",
            "uid": "DummyUser",
            "displayName": "DummyUser",
            "type": 0
          },
          "cardId": 288,
          "type": 0
        }
      ],
      "attachments": null,
      "attachmentCount": 1,
      "owner": {
        "primaryKey": "DummyUser",
        "uid": "DummyUser",
        "displayName": "DummyUser",
        "type": 0
      },
      "order": 6,
      "archived": false,
      "duedate": null,
      "deletedAt": 0,
      "commentsUnread": 0,
      "id": 288,
      "ETag": "dummy-etag-hash-value"
      "overdue": 0
    }
  }
]

Information on your n8n setup

  • n8n version:0.153.0
  • Database you’re using: SQLite
  • Running n8n with the execution process [own(default), main]: don’t know
  • Running n8n via: Docker

Hi @mfreudenberg, I think the problem would be with the expression in this case rather than the IF node.

In your condition you use the expression {{$node["GetDateTime"].json["currentDate"]}}. Now for the first item the IF node receives, this expression would read the currentDate value from the first item on the GetDateTime node which is fine. But for the second item the IF node receives if would read the currentDate value from the second item on the GetDateTime node and so on. Since GetDateTime has only one item, the comparison would fail for all subsequent items.

An easy solution would be to put $item(0) in front of your expression like this {{$item(0).$node["GetDateTime"].json["currentDate"]}}. Now the expression will always reference the first (and only) item from your GetDateTime node:

Let me know if you run into any trouble with this!