cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Seuadr
Helper IV
Helper IV

Filter Array woes - 'Filter_array' failed:The provided value is of type 'Object'.

Hi all,

 

I am confused - I am trying to take response details from a  form submission, put them in an array, and filter for length.

 

here is my flow:

Seuadr_1-1625061208201.png

 


here are my inputs/outputs:

JSON inputs:
{
  "responder": "ipf.sa.hvacflow@msu.edu",
  "submitDate": "6/30/2021 12:55:00 PM",
  "r2fd4e52c503546c199c3869b95b02375": "response",
  "r23b2747015474c219b0d3946db0e5653": "Pre Implementation Validation",
  "rc9512ec9e1a14bf8a7e0ea10148678f3": "Validate the equipment class",
  "re1091ddaff7e40af84fc3b1405d3b17d": "",
  "r007f98f267f14c5ea21ff5e2ecd892e7": "",
  "rf4838fcf300e45a3b06ff7aa4bbef80b": "Build the Bulk Template",
  "r182391eeefcc4a83a900d7578b04fd92": ""
}

JSON outputs:

  "responder": "ipf.sa.hvacflow@msu.edu",
  "submitDate": "6/30/2021 12:55:00 PM",
  "r2fd4e52c503546c199c3869b95b02375": "response",
  "r23b2747015474c219b0d3946db0e5653": "Pre Implementation Validation",
  "rc9512ec9e1a14bf8a7e0ea10148678f3": "Validate the equipment class",
  "re1091ddaff7e40af84fc3b1405d3b17d": "",
  "r007f98f267f14c5ea21ff5e2ecd892e7": "",
  "rf4838fcf300e45a3b06ff7aa4bbef80b": "Build the Bulk Template",
  "r182391eeefcc4a83a900d7578b04fd92": ""
}
Compose_2 output:
[
  {
    "responder": "ipf.sa.hvacflow@msu.edu",
    "submitDate": "6/30/2021 12:55:00 PM",
    "r2fd4e52c503546c199c3869b95b02375": "response",
    "r23b2747015474c219b0d3946db0e5653": "Pre Implementation Validation",
    "rc9512ec9e1a14bf8a7e0ea10148678f3": "Validate the equipment class",
    "re1091ddaff7e40af84fc3b1405d3b17d": "",
    "r007f98f267f14c5ea21ff5e2ecd892e7": "",
    "rf4838fcf300e45a3b06ff7aa4bbef80b": "Build the Bulk Template",
    "r182391eeefcc4a83a900d7578b04fd92": ""
  }
]
Filter array input:
outputs('Compose_2')

Filter Array Expresison:
length(item())

Filter Array error Message:
InvalidTemplate. The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@greater(length(item()), 1)' failed: 'The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#length for usage details.'.

 

I am confused, because i have several flows that do the same thing from plaintext emails and i don't get this error i added the parse JSON because i was thinking that the compose_2 was perhaps having issues with the output from get response details, but, it seems to be the same either way.

i also tried an apply to each with the filter array action being "current item" but get the same error.

 

i am not sure how to approach this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User III
Super User III

You can do it like this:

https://ibb.co/68KpLsy

RemoveEmptyElements.png

The output produced is:

[
  "<responder>ipf.sa.hvacflow@msu.edu</responder>",
  "<submitDate>6/30/2021 12:55:00 PM</submitDate>",
  "<r2fd4e52c503546c199c3869b95b02375>response</r2fd4e52c503546c199c3869b95b02375>",
  "<r23b2747015474c219b0d3946db0e5653>Pre Implementation Validation</r23b2747015474c219b0d3946db0e5653>",
  "<rc9512ec9e1a14bf8a7e0ea10148678f3>Validate the equipment class</rc9512ec9e1a14bf8a7e0ea10148678f3>",
  "<rf4838fcf300e45a3b06ff7aa4bbef80b>Build the Bulk Template</rf4838fcf300e45a3b06ff7aa4bbef80b>"
]

 

View solution in original post

6 REPLIES 6
Paulie78
Super User III
Super User III

It's because you are trying to use length on a whole object, in your case:

  {
    "responder": "ipf.sa.hvacflow@msu.edu",
    "submitDate": "6/30/2021 12:55:00 PM",
    "r2fd4e52c503546c199c3869b95b02375": "response",
    "r23b2747015474c219b0d3946db0e5653": "Pre Implementation Validation",
    "rc9512ec9e1a14bf8a7e0ea10148678f3": "Validate the equipment class",
    "re1091ddaff7e40af84fc3b1405d3b17d": "",
    "r007f98f267f14c5ea21ff5e2ecd892e7": "",
    "rf4838fcf300e45a3b06ff7aa4bbef80b": "Build the Bulk Template",
    "r182391eeefcc4a83a900d7578b04fd92": ""
  }

You can only use length on an array, or a string. I presume you are trying to test the length of one of the properties of that object, so you could do something like 

length(item()['responder'])

or you could get the entire length of the object by doing something like:

length(string(item()))

 What is it you are actually trying to achieve, it does not make complete sense to me.

Paulie78,

 

Thanks for the quick response!

My end goal is to omit any array entries that have no value entered in the response:

Seuadr_0-1625062765055.png

 

Regards,

 

Jared



Paulie78
Super User III
Super User III

You can do it like this:

https://ibb.co/68KpLsy

RemoveEmptyElements.png

The output produced is:

[
  "<responder>ipf.sa.hvacflow@msu.edu</responder>",
  "<submitDate>6/30/2021 12:55:00 PM</submitDate>",
  "<r2fd4e52c503546c199c3869b95b02375>response</r2fd4e52c503546c199c3869b95b02375>",
  "<r23b2747015474c219b0d3946db0e5653>Pre Implementation Validation</r23b2747015474c219b0d3946db0e5653>",
  "<rc9512ec9e1a14bf8a7e0ea10148678f3>Validate the equipment class</rc9512ec9e1a14bf8a7e0ea10148678f3>",
  "<rf4838fcf300e45a3b06ff7aa4bbef80b>Build the Bulk Template</rf4838fcf300e45a3b06ff7aa4bbef80b>"
]

 

View solution in original post

Paulie78
Super User III
Super User III

Actually change the xpath expression to:

xpath(outputs('XML'), '//root/entries/*/text()')

and delete the select action. Then the output will be:

[
  "ipf.sa.hvacflow@msu.edu",
  "6/30/2021 12:55:00 PM",
  "response",
  "Pre Implementation Validation",
  "Validate the equipment class",
  "Build the Bulk Template"
]

Bit cleaner.

Seuadr
Helper IV
Helper IV

Thanks! I am working on implementing this, but, i think i've gone awry somewhere - 

My XML output is:

<root><entries><body><responder>ipf.sa.hvacflow@msu.edu</responder><submitDate>6/30/2021 12:55:00 PM</submitDate><r2fd4e52c503546c199c3869b95b02375>response</r2fd4e52c503546c199c3869b95b02375><r23b2747015474c219b0d3946db0e5653>Pre Implementation Validation</r23b2747015474c219b0d3946db0e5653><rc9512ec9e1a14bf8a7e0ea10148678f3>Validate the equipment class</rc9512ec9e1a14bf8a7e0ea10148678f3><re1091ddaff7e40af84fc3b1405d3b17d></re1091ddaff7e40af84fc3b1405d3b17d><r007f98f267f14c5ea21ff5e2ecd892e7></r007f98f267f14c5ea21ff5e2ecd892e7><rf4838fcf300e45a3b06ff7aa4bbef80b>Build the Bulk Template</rf4838fcf300e45a3b06ff7aa4bbef80b><r182391eeefcc4a83a900d7578b04fd92></r182391eeefcc4a83a900d7578b04fd92></body></entries></root>

but the xpath input is []

Seuadr_0-1625065379744.png

 



Seuadr
Helper IV
Helper IV

I figured it out - instead of selecting specific nodes, i just selected all of the nodes:

xpath(outputs('XML'), '//node()/text()')
 
this might normally be a bad idea, but, since i have a very limited selection of items, it seems to work fine.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,424)