power-automate

Power Automate - Filter array on string value


In Power Automate I have a Filter array data operation which retrieves the following JSON Input:

[
  {
    "id": "123",
    "email": "testemail@icloud.com",
    "mobilePhone": "",
    "countryCode": "TR",
    "preferences": {
      "acceptsEmail": "true"
    }
  },
  {
    "id": "1234",
    "email": "testemail@hotmail.com",
    "mobilePhone": "",
    "countryCode": "BE",
    "preferences": {
      "acceptsEmail": "false"
    }
  }
]

Notice that the value of the acceptsEmail key is a "true" or "false" string and not a boolean.

Im trying to do the following to filter out all occurences of "preferences": { "acceptsEmail": "false" }

In the filter query i use item()?['preferences']?['acceptsEmail'] in the first field, is equal to in the second field, and false in the third field. When I run the flow the output body is empty and I cant seem to understand why, but im guessing its due to the string values of "true"/"false" not being found by my query.


Solution

  • update the third field as expression string('false') to convert it as a string and be able to filter properly

    enter image description here

    output: enter image description here