Home > Enterprise >  azure logic app: not corrently checking empty check
azure logic app: not corrently checking empty check

Time:08-01

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

CodePudding user response:

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
            ]
          }
        }
      ]
    },
    ...
  }
}

CodePudding user response:

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"
                        ]
                    }
                ]
            }
  • Related