Fisqkuz
Fisqkuz

Reputation: 99

azure logic app: not corrently checking empty check

The following logic app is triggered at 10 AM and runs a SQL server query. As you can tell from the picture the resultsets are empty.

The conditional check checks whether the resultssets of the query is empty. (2nd pic)

How does this still translate into a True? The result is clearly empty.

enter image description here

enter image description here

Upvotes: 0

Views: 790

Answers (2)

Fisqkuz
Fisqkuz

Reputation: 99

Anyway, I found another way. For future refence my solution was as follows:

            "Compose": {
            "inputs": "@empty(body('query')?['resultsets'])",
            "runAfter": {
                "query": [
                    "Succeeded"
                ]
            },
                "expression": {
                "and": [
                    {
                        "equals": [
                            "@outputs('Compose')",
                            "@true"
                        ]
                    }
                ]
            }

Upvotes: 0

Thomas
Thomas

Reputation: 29492

With your condition, you are trying to compare an array to a boolean.

Instead you could check if the length of the array is not equal to 0:

{
  "Condition": {
    ...
    "expression": {
      "and": [
        {
          "not": {
            "equals": [
              "@length(body('query')?['resultsets'])",
              0
            ]
          }
        }
      ]
    },
    ...
  }
}

Upvotes: 2

Related Questions