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:
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?
Solved! Go to Solution.
You can do it like this:
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>"
]
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:
Regards,
Jared
You can do it like this:
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>"
]
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.
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 []
I figured it out - instead of selecting specific nodes, i just selected all of the nodes:
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
68 | |
22 | |
16 | |
16 | |
11 |
User | Count |
---|---|
130 | |
42 | |
32 | |
32 | |
28 |