Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The function contains() is broken evaluating an array, for a given value from another array. #1312

Open
BaHAlexP opened this issue Mar 10, 2025 · 0 comments

Comments

@BaHAlexP
Copy link

BaHAlexP commented Mar 10, 2025

Describe the Bug

Please note the below is being done in PowerAutomate and not Logic Apps, but my understanding is the functions used in PowerAutomate are the same as Logic Apps and hence logging the bug here.

The function contains() when evaluating an array of integers for a given integer value from another array, the contains result returns "false", where the expected result is "true".

The contains() function documentation
https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#contains

states this should be possible.

See reproduction steps below to understand.

Plan Type

Standard

Steps to Reproduce the Bug or Issue

To replicate, please create a new flow and follow the below. Please note i used the "SELECT" in this way to try and understand why a different flow was not working, that is to visually demonstrate the inputs/outputs from the evaluations.

I have two arrays containing integers, which I want to compare:

First Array (contains all numbers in a range)

[
84,
85,
86,
87
]

Image

Second Array (contains just two of the number in the above range)

[
87,
84,
]

Image

Select:

Image

Note

In the above image titled "Select":

"From" = body('FirstArrayRange') >> First Array (as described above)

Mappings:
"id" = item() >> (current item from 'FirstArrayRange')
"evaluationResults" = contains(body('SecondArrayIds'), item())
"selectIds" = body('SecondArrayIds') >> Second Array (as described above)

Actual Results

[
{
"id": 84,
"evaluationResult": false,
"selectIds": [
87,
84
]
},
{
"id": 85,
"evaluationResult": false,
"selectIds": [
87,
84
]
},
{
"id": 86,
"evaluationResult": false,
"selectIds": [
87,
84
]
},
{
"id": 87,
"evaluationResult": false,
"selectIds": [
87,
84
]
}
]

Expected Result

[
{
"id": 84,
"evaluationResult": true,
"selectIds": [
87,
84
]
},
{
"id": 85,
"evaluationResult": false,
"selectIds": [
87,
84
]
},
{
"id": 86,
"evaluationResult": false,
"selectIds": [
87,
84
]
},
{
"id": 87,
"evaluationResult": true,
"selectIds": [
87,
84
]
}
]

Note the Workflow JSON is a copy of the SCOPE containing all the relevant code.

Workflow JSON

{
  "id": "648c8d43-9fc9-4a62-bcc0-91cb900c3317",
  "brandColor": "#8C3900",
  "connectionReferences": {
    "shared_sharepointonline_1": {
      "connection": {
        "id": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/a0daba5c68b1463a8a1e2d4383ba273b"
      }
    }
  },
  "connectorDisplayName": "Control",
  "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=",
  "isTrigger": false,
  "operationName": "Scope",
  "operationDefinition": {
    "type": "Scope",
    "actions": {
      "FirstArrayRange": {
        "type": "Select",
        "inputs": { "from": "@variables('Range')", "select": "@item()" },
        "runAfter": {},
        "metadata": {
          "operationMetadataId": "5b7914c5-f859-43f1-a4e6-bf2b2efa2a0b"
        }
      },
      "SecondArrayIds": {
        "type": "Select",
        "inputs": {
          "from": "@outputs('Get_items')?['body/value']",
          "select": "@item()?['AttachmentId']"
        },
        "runAfter": { "FirstArrayRange": ["Succeeded"] },
        "metadata": {
          "operationMetadataId": "d6a2c59d-ccd2-4025-9149-fbaa13c91a6a"
        }
      },
      "Select": {
        "type": "Select",
        "inputs": {
          "from": "@body('FirstArrayRange')",
          "select": {
            "id": "@item()",
            "evaluationResult": "@contains(body('SecondArrayIds'), item())",
            "selectIds": "@body('SecondArrayIds')"
          }
        },
        "runAfter": { "SecondArrayIds": ["Succeeded"] },
        "metadata": {
          "operationMetadataId": "30e41bea-2158-4755-91a7-040f71205fd9"
        }
      }
    },
    "runAfter": { "Initialize_variable": ["Succeeded"] }
  }
}

Screenshots or Videos

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant