-
Notifications
You must be signed in to change notification settings - Fork 307
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
Comments
I'm not discounting your problems, @BaHAlexP , because I've reported issues with the contains() myself recently (and, I am guessing that that it might be related to a hidden 'upgrade' of the contains() functionality which now reports on key names in objects which if mightily useful), but I cannot seem to replicate your issue, even with your code: Here is the code of that working result to copy / paste into your flow: {"id":"7dfb5f15-dbb7-4af7-b88c-b2f308fc098b","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":{"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"}},"Get_items":{"type":"Compose","inputs":{"body":{"value":[{"AttachmentId":87},{"AttachmentId":84}]}},"runAfter":{}},"FirstArrayRange":{"type":"Select","inputs":{"from":"@variables('Range')","select":"@item()"},"runAfter":{"Get_items":["Succeeded"]},"metadata":{"operationMetadataId":"5b7914c5-f859-43f1-a4e6-bf2b2efa2a0b"}}},"runAfter":{"Initialize_Range":["Succeeded"]}}} Here's my alternative look at it: {"nodeId":"Scope_Hrm-copy","serializedValue":{"type":"Scope","actions":{"ConstantsObjCNST":{"type":"ParseJson","inputs":{"content":{"arrayOne":[84,85,86,87],"arrayTwo":[87,84]},"schema":{"title":"Arrays","type":"object","properties":{"arrayOne":{"title":"- One","type":"array","items":{"title":"- Item (One)","type":"integer"}},"arrayTwo":{"title":"- Two","type":"array","items":{"title":"- Item (Two)","type":"integer"}}}}}},"SelectMyWay":{"type":"Select","inputs":{"from":"@body('ConstantsObjCNST')?['arrayOne']","select":{"id":"@item()","evaluationResults":"@contains(\r\n\tbody('ConstantsObjCNST')?['arrayTwo'], \r\n item()\r\n)","selectIds":"@body('ConstantsObjCNST')?['arrayTwo']"}},"runAfter":{"ConstantsObjCNST":["Succeeded"]}},"SecondArrayIds":{"type":"Select","inputs":{"from":"@body('ConstantsObjCNST')?['arrayTwo']","select":"@item()"},"runAfter":{"ConstantsObjCNST":["Succeeded"]}},"FirstArrayRange":{"type":"Select","inputs":{"from":"@body('ConstantsObjCNST')?['arrayOne']","select":"@item()"},"runAfter":{"ConstantsObjCNST":["Succeeded"]}},"Select":{"type":"Select","inputs":{"from":"@body('FirstArrayRange')","select":{"id":"@item()","evaluationResults":"@contains(\r\n\tbody('SecondArrayIds'), \r\n item()\r\n)","selectIds":"@body('SecondArrayIds')"}},"runAfter":{"FirstArrayRange":["Succeeded"],"SecondArrayIds":["Succeeded"]}}},"runAfter":{}},"allConnectionData":{},"staticResults":{},"isScopeNode":true,"mslaNode":true} That also worked. |
@influential-eliot thanks for taking the time out to look at it, it's much appreciated. It's interesting you can't replicate it, which suggests things are not consistent across users. Something is definitely "not right" somewhere, but where.. I have no idea. Also, it's interesting that you said you have been having issues with contain and the linked github bug you have reported re a not contains, does not work. Is actually the same experience i had (not contains, not working), which lead me to the above issue i reported, where i believe it's the underlying contains() function that's broken (as shown above), because the not(), is just reversing whatever is passed in from contains() So, i took the first code you put above, and inserted it into my existing flow.. it worked.. that is it returned the correct / expected result. Interestingly.. as soon as i edited the items in the SCOPE (the code you provided), specifically removing Get Items 2 and amending SecondArrayIds to reference the SharePoint Connector returned results.. it then did not work. There's no meaningful difference between the Get Items 2 and the SharePoint connectors returned results, other than the obvious default properties that are returned. I am puzzled as to why it broke it. In the below screenshots the code on the left is the edited version of your code, the code on the right is your code. @hartra344 @AbodeSaafan any ideas? |
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
]
Second Array (contains just two of the number in the above range)
[
87,
84,
]
Select:
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
Screenshots or Videos
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: