Mikkel Fennefoss
Mikkel Fennefoss

Reputation: 911

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": "[email protected]",
    "mobilePhone": "",
    "countryCode": "TR",
    "preferences": {
      "acceptsEmail": "true"
    }
  },
  {
    "id": "1234",
    "email": "[email protected]",
    "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.

Upvotes: 0

Views: 64

Answers (1)

frue
frue

Reputation: 86

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

Upvotes: 2

Related Questions