cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MPoe
Level: Powered On

Using Filter action does not filter Array Variable

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:

flow_question_03.PNG

 

Appending an error message:

flow_question_04.PNG

 

Filter view in edit mode. The advanced mode formula is:

@equals('isSuccess', 'False')

flow_question_02.PNG

 

Results from a test run showing that the filter isn't picking up any of the isSuccess = False records:

flow_question_01.PNG

 

Any help would be most appreciated! Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Using Filter action does not filter Array Variable

Hi @MPoe 

 

it cannot be IsSuccess as a string

 

IsSuccess should be from an expression that looks like this (use expression)

 

item()?['IsSuccess']

13 REPLIES 13
Super User
Super User

Re: Using Filter action does not filter Array Variable

@MPoe 

Hi there.  In the Filter, have you already tried putting the False in single quotes like a string?

 

-Ed-

MPoe
Level: Powered On

Re: Using Filter action does not filter Array Variable

Hi @edgonzales , yes. I've tried both

@equals('isSuccess', False)

and

@equals('isSuccess', 'False')

but neither returns the intended array items =/

Super User
Super User

Re: Using Filter action does not filter Array Variable

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-

MPoe
Level: Powered On

Re: Using Filter action does not filter Array Variable

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

Super User
Super User

Re: Using Filter action does not filter Array Variable

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

MPoe
Level: Powered On

Re: Using Filter action does not filter Array Variable

Hi @RezaDorrani it did not work, it still returns an empty array. Here are the screen shots:

Initializing the variable:

false as string.PNG

 

Putting it into use:

filter on false as string.PNG

Super User
Super User

Re: Using Filter action does not filter Array Variable

Hi @MPoe 

 

it cannot be IsSuccess as a string

 

IsSuccess should be from an expression that looks like this (use expression)

 

item()?['IsSuccess']

Super User
Super User

Re: Using Filter action does not filter Array Variable

@RezaDorrani 

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-

Super User
Super User

Re: Using Filter action does not filter Array Variable

@RezaDorrani That fixed it for me...I was just reading about that here.

 

@MPoe - Did that solve the issue for you?

 

MPoe
Level: Powered On

Re: Using Filter action does not filter Array Variable

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?

Highlighted
Super User
Super User

Re: Using Filter action does not filter Array Variable

Hi @edgonzales 

 

Just tested it and worked

Untitled.png

 

Super User
Super User

Re: Using Filter action does not filter Array Variable

@MPoe 

existing post is fine

Beck0Fish
Level: Powered On

Re: Using Filter action does not filter Array Variable

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.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 193 members 4,459 guests
Please welcome our newest community members: