Skip to main content

Notifications

Community site session details

Community site session details

Session Id : YYgMovYdTEOh8xqLFu1VsN
Power Automate - Building Flows
Suggested answer

filtering an array of json objects and building an html table.

Like (0) ShareShare
ReportReport
Posted on 19 Dec 2024 01:48:23 by 27
Hello, 
 
I'm attempting to process a JSON response from an HTTP request and when the endDate is sooner than 60 days, add the details into an html table.  
 
My HTTP Response looks like this: 
 
{
    "detail": [
        {
            "product": "productName",
            "systemId": 12345,
            "productId": 5,
            "endDate": "2025-01-31",
            "company": "Contoso",
            "location": "Seattle",
            "projectName": "7859"
        },
        {
            "product": "productName2",
            "machineId": 23456,
            "productId": 5,
            "endDate": "2025-05-13",
            "company": "Acme",
            "location": "Chicago",
            "projectName": "8404"
        }
    ]
}
 
This is my flow
 
 
And this fails with the following message: 
 
The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_Each')' is of type 'Object'. The result must be a valid array.
 
Can anyone share some advice?  TIA! 
  • TP-09081649-0 Profile Picture
    27 on 19 Dec 2024 at 20:40:30
    filtering an array of json objects and building an html table.
    Disregard my last post, through some other examples I realized that I was over complicating it and built the HTML table from the Filter Body instead of from items in the body. 
     
    Thanks! 
  • TP-09081649-0 Profile Picture
    27 on 19 Dec 2024 at 17:35:16
    filtering an array of json objects and building an html table.
    @Nived and @Chriddle,
     
    Thank you for that advice, definitely a useful Filter, however I don't think that helps with adding it to a visual table for email as the result is still an array of JSON objects: 
     
    [
      {
        "product""productName",
        "systemId"12345,
        "productId"5,
        "endDate""2025-01-31",
        "company""Contoso",
        "location""Seattle",
        "projectName""7859"
      }
    ]
     
    I'm still having trouble selecting an input for Create HTML Table that doesn't require For Each loop hitting the same error. 
     
  • Chriddle Profile Picture
    7,708 Super User 2025 Season 1 on 19 Dec 2024 at 08:17:28
    filtering an array of json objects and building an html table.
    This filter is a bit simpler (IMHO)
    item()['endDate'] is less than addDays(utcNow(), 60, 'yyyy-MM-dd')
  • Suggested answer
    Nived_Nambiar Profile Picture
    17,554 Super User 2025 Season 1 on 19 Dec 2024 at 03:16:48
    filtering an array of json objects and building an html table.
     
     
    Since you have looped through Current Item dynamic content which is an object - that's why you got the issue.
     
    I have designed a demo flow which would not be using loops as shown below
     
     
     
     
    div(sub(ticks(item()?['endDate']),ticks(formatDateTime(utcNow(),'yyyy-MM-dd'))),864000000000)
     
     
    Hope it helps !
     

    Thanks & Regards,
    Nived N

    Stay connected:
    LinkedIn | YouTube | Blogs

    Was this answer helpful?
    If yes, please mark it as the solution by selecting the checkbox in the discussion thread.
    Your feedback motivates me to keep contributing. Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 79

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 70 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard