Neo
Neo

Reputation: 16219

How to use contains to compare property value from one array to another array logic app expression?

I have two arrays variables and values like below

arraydata1 =

[
  {
    "id": "1",
    "name": "aaa"
  },
  {
    "id": "2",
    "name": "bbb"
  },
  {
    "id": "3",
    "name": "ccc"
  },
  {
    "id": "4",
    "name": "ddd"
  },
 {
    "id": "14",
    "name": "bbb"
  }
]

arraydata2 =

[
  {
    "id": "111",
    "tablename": "aaa"
  },
  {
    "id": "222",
    "tablename": "bbb"
  }
]

output -

[
       {
        "id": "1",
        "name": "aaa"
      },
      {
        "id": "2",
        "name": "bbb"
      },
     {
        "id": "14",
        "name": "bbb"
      },
    ]

using 2 foreach also i'm able to achieve this but it takes time to compare.

also tried using taken a for-each connector and inside that used contains expression to compare name and tablename but for all values it is false.

contains(variables('arraydata2'),items('For_each')?['tablename'])

can we do it without using 2 foreach

enter image description here

Upvotes: 1

Views: 3415

Answers (1)

AdAstra
AdAstra

Reputation: 1984

//Updated to one for each loop:

The following will return 2 objects, you won't get the true reply but you will have the objects instead.

items('For_each')['name'] and item()['tablename']

enter image description here

Upvotes: 2

Related Questions