I am using a flow to hit an API for all accounts associated with a given account group. It's being triggered from the account group page in Dyanmics 365, and I'm using a flow defined Array Variable to store the respones from the API call. Then I post a note to the account group entity's timeline based on the API responses. All success and all fail are easy, but when I try to filter out to determine which are success and which failed, it doesn't seem to filter at all. Can anyone point out what I've got wrong with my filter here?
The text of what is hitting my filter is this:
[ { "acctNumber": "xxxx-1", "isSuccess": "False", "message": "Requires, but does not have, an Account Name!" }, { "acctNumber": "xxxx-2", "isSuccess": "False", "message": "Requires, but does not have, an Account Name!" }, { "acctNumber": "xxxx-3", "isSuccess": "True", "message": "Data requested successfully. Like a boss." }, { "acctNumber": "xxxx-4", "isSuccess": "True", "message": "Data requested successfully. Like a boss." } ]
Screenshot of the variable initialization:
Appending an error message:
Filter view in edit mode. The advanced mode formula is:
@equals('isSuccess', 'False')
Results from a test run showing that the filter isn't picking up any of the isSuccess = False records:
Any help would be most appreciated! Thanks!
Solved! Go to Solution.
Hi @MPoe
it cannot be IsSuccess as a string
IsSuccess should be from an expression that looks like this (use expression)
item()?['IsSuccess']
Hi there. In the Filter, have you already tried putting the False in single quotes like a string?
-Ed-
Hi @edgonzales , yes. I've tried both
@equals('isSuccess', False)
and
@equals('isSuccess', 'False')
but neither returns the intended array items =/
Something is broken... I followed this write-up exactly and am seeing the same thing you are even with their data.
I don't like that in the write-up, the field for the filter shows as dynamic, but for your data, AND the one in the sample, I had to use the advanced filter.
I even tried reconstructing the array one unit at a time and then filtering.
I'll keep at it, but wanted to give you an update from my side. Maybe someone else has some thoughts.
-Ed-
Glad to hear it's not just me. I was following the same documentation and got the same feeling that it may have something to do with the dynamic vs static field name. I'll keep trying on my side as well
Hi @MPoe
Initialize a variable of type string and set its value to False
Then in your condition compare against this variable
it should work
Regards,
Reza Dorrani
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @RezaDorrani it did not work, it still returns an empty array. Here are the screen shots:
Initializing the variable:
Putting it into use:
Hi @MPoe
it cannot be IsSuccess as a string
IsSuccess should be from an expression that looks like this (use expression)
item()?['IsSuccess']
Same results on my side. Even when I try with the simpler array in the sample data from the example (link above).
Do you know why the field isn't showing in the dynamic values list?
-Ed-
@RezaDorrani That fixed it for me...I was just reading about that here.
@MPoe - Did that solve the issue for you?
That's it! The False as String variable isn't needed as long as you get False converted to a string in the expression
@equals(item()?['isSuccess'], 'False')
@RezaDorrani do you want me to mark your existing post as the answer or do you want to put the pieces all in one place and I can mark that one?
existing post is fine
Pasting a copy here in case this simpler issue I had saves anyone the research that led me here - not as complex as above example with strings etc. but item() did it for me too.
What I wanted was even simpler than what they partially demo'd in the MS link for Filter array: I had a Variable of type Array of whole numbers (1s, 2s, or 3s) and wanted to display how many of these were number 3. In the Filter Array action my 'From' was the Array (available under Variables in Dynamic Content) and my operator 'is equal to' and value 3. Your mention of 'item' helped me figure out the first part of the equation - item() on its own ended up working as a pasted expression (note NO parameters). The advanced mode looked like this: @equals(item(), 3)
I could then use length(body('Filter_array')) to get a count of how many that filter caught.
User | Count |
---|---|
84 | |
81 | |
48 | |
30 | |
23 |
User | Count |
---|---|
28 | |
28 | |
27 | |
21 | |
20 |