Pre-action workflow always true when comparing array length

Hello,
We have a collections that has a many to many relation with Teams and while submitting the object we want to check that the number of teams selected is less that a value or constant but this condition always return true.
It seems like the condition don’t check the length of the object.
Exemple:

"params": {
    "filterByTk": "14",
    "values": {
      "id": 14,
      "createdAt": "2024-08-06T10:17:03.561Z",
      "updatedAt": "2024-08-06T10:23:01.038Z",
      "nameAr": "c1",
      "nameEn": "c1",
      "type": "Cup",
      "status": "Upcoming",
      "description": null,
      "organizingCountry": null,
      "startAt": "2024-08-13T23:00:00.000Z",
      "endAt": "2024-08-29T23:00:00.000Z",
      "numberOfTeams": 1,
      "createdById": 26,
      "updatedById": 26,
      "teams": [
        {
          "id": 1,
          "createdAt": "2024-07-12T11:42:41.305Z",
          "updatedAt": "2024-07-30T14:34:07.043Z",
          "shortNameEn": "team 1",
          "shortNameAr": "team 1",
          "establishedDate": null,
          "association-ID": 1,
          "team-manager-email": "team1@mail.com",
          "fullNameAr": "team 1",
          "fullNameEn": "team 1",
          "createdById": 1,
          "updatedById": 26,
          "TeamCompetition": {
            "id": 52,
            "createdAt": "2024-08-06T10:17:03.584Z",
            "updatedAt": "2024-08-06T10:17:03.584Z",
            "TeamIDname": "team 1",
            "competitionIDname": "c1",
            "createdById": 26,
            "updatedById": 26
          }
        },
        {
          "id": 2,
          "createdAt": "2024-07-12T11:50:30.699Z",
          "updatedAt": "2024-07-26T09:15:47.896Z",
          "shortNameEn": "team 2",
          "shortNameAr": "team 2",
          "establishedDate": null,
          "association-ID": 1,
          "team-manager-email": "team2@mail.com",
          "fullNameAr": "team 2",
          "fullNameEn": "team 2",
          "createdById": 1,
          "updatedById": 1,
          "TeamCompetition": {
            "id": 53,
            "createdAt": "2024-08-06T10:17:03.584Z",
            "updatedAt": "2024-08-06T10:17:03.584Z",
            "TeamIDname": "team 2",
            "competitionIDname": "c1",
            "createdById": 26,
            "updatedById": 26
          }
        },
        {
          "id": 3,
          "createdAt": "2024-07-12T13:10:18.846Z",
          "updatedAt": "2024-07-17T07:58:53.828Z",
          "shortNameEn": "team 3",
          "shortNameAr": "team 3",
          "establishedDate": null,
          "association-ID": 2,
          "team-manager-email": null,
          "fullNameAr": "team 3",
          "fullNameEn": "team 3",
          "createdById": 1,
          "updatedById": 1,
          "TeamCompetition": {
            "id": 54,
            "createdAt": "2024-08-06T10:17:03.584Z",
            "updatedAt": "2024-08-06T10:17:03.584Z",
            "TeamIDname": "team 3",
            "competitionIDname": "c1",
            "createdById": 26,
            "updatedById": 26
          }
        },
        {
          "id": 5,
          "createdAt": "2024-07-16T10:26:48.510Z",
          "updatedAt": "2024-07-26T13:17:19.529Z",
          "shortNameEn": "Team 5",
          "shortNameAr": "Team 5",
          "establishedDate": "2022-01-12T00:00:00.000Z",
          "association-ID": 1,
          "team-manager-email": "mail@hedi.com",
          "fullNameAr": "Team 5",
          "fullNameEn": "Team 5",
          "createdById": null,
          "updatedById": 26,
          "TeamCompetition": {
            "id": 55,
            "createdAt": "2024-08-06T10:17:03.584Z",
            "updatedAt": "2024-08-06T10:17:03.584Z",
            "TeamIDname": "Team 5",
            "competitionIDname": "c1",
            "createdById": 26,
            "updatedById": 26
          }
        }
      ]
    }
  }

Node result:
false

The condition is not a length comparison, but a content comparison. You can use a calculation node to calculate the length of the array before comparing.

1 Like

Thank you, solved.