web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to add JSON nested...
Power Automate
Unanswered

How to add JSON nested array to HTML table?

(0) ShareShare
ReportReport
Posted on by 8

Any help with this would be really appreciated as I've been trying for a few days - trying to keep this a short post but if more information is needed please let me know.

 

I am trying to create a HTML table (example below) from JSON, which has root level information and two nested arrays containing multiple item(s) in each array. I want to output this to a HTML table (example below). I have tried creating an apply to each for 1 of the nested arrays and I can access the data in the array and append it to a variable, which I can then add to the HTML table but I just get duplicates of all items in the array on the HTML table instead of only items/variables that only relate to that row/item?

 

For info the JSON is coming from the common data service get items on Dynamics 365 cases 

 

Root Level NameRoot Level NumberData in 1st array (all items merged)Data in 2nd array (all items merged)
   

 

 

 

 

 

Categories:
I have the same question (0)
  • v-litu-msft Profile Picture
    on at

    Hi @dan92,

     

    According to your description of the requirement, I structure an object as below, then I convert the array into the string by using join() function, separated by ",", hope this is what you want:

    Screenshot 2020-09-16 132932.jpg

     

    Screenshot 2020-09-16 133020.jpg

     

    Run result:

    Screenshot 2020-09-16 133142.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • dvn92 Profile Picture
    8 on at

    Hi @v-litu-msft 

     

    I really appreciate your reply and help

     

    The problem is (sorry I didn't explain very well) that I have multiple values being returned so the data structure is more like:

     

    • Logged Item 1 (root)
    • Reference Item 1 (root)
      • Array 1 for item 1 
        • Value(s) I want to access
        • Value(s) I want to access
        • Value(s) I want to access
      • Array 2 for item 1
        • Value I want to access
        • Value(s) I want to access
        • Value(s) I want to access
    • Logged Item 2 (root)
    • Reference Item 2 (root)
      • Array 1 for item 2
        • Value(s) I want to access
        • Value(s) I want to access
        • Value(s) I want to access
      • Array 2 for item 2
        • Value(s) I want to access
        • Value(s) I want to access
        • Value(s) I want to access

    Etc...

     

    I wanted to try to output a HTML table from the above as below:

     

    Logged Item 1 (root)

    Reference Item 1 (root)

    Array 1 for item 1

    All Value(s) I want to access merged

    Array 2 for item 1
    All Value(s) I want to access merged

    Logged Item 2 (root)

    Reference Item 2 (root)Array 1 for item 2
    All Value(s) I want to access merged
    Array 2 for item 2
    All Value(s) I want to access merged

     

  • v-litu-msft Profile Picture
    on at

    Hi @dan92,

     

    Sorry, could you please share an instance of the JSON with fake value?

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • dvn92 Profile Picture
    8 on at

    Hi @v-litu-msft 

     

    Sure and thank you again for the help! Below is a copy of the JSON, I have anonimised and removed some parts which aren't relevant to keep it short.

     

    The JSON contains 3 "cases" (root level) from Dynamics, some of which have notes (Incident_Annotation) and emails (Incident_Emails) in the respective nested arrays which is what I want to add to my HTML table. So based on the JSON example here is what I want to do in the HTML table is as below:

     

    LoggedReferenceNotesEmails
    10/09/2020 13:47
    (createdon@OData.Community.Display.V6.FormattedValue)
    CAS-06055-Q0B6F9
    (ticketnumber)
    a test note about something
    This is a note text again
    (Incident_Annotation - notetext from all)
    test email about something
    another test email about something
    (Incident_Emails - description from all)
    10/09/2020 11:32
    (createdon@OData.Community.Display.V6.FormattedValue)
    CAS-06059-R5Z6Y0
    (ticketnumber)
     
     
    10/09/2020 11:41
    (createdon@OData.Community.Display.V6.FormattedValue)
    CAS-06054-Y9P0R0
    (ticketnumber)
    test notes
    (Incident_Annotation - notetext from all)
     

     

     

    [
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.incident",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/incidents(d976ea6b-6cf9-ea66-a967-000d9a7fcd6e)",
     "@odata.etag": "W/\"9977905\"",
     "@odata.editLink": "incidents(d976ea6b-6cf9-ea66-a967-000d9a7fcd6e)",
     "description": "This is test case 1 which has notes (Incident_Annotation) and emails (Incident_Emails)",
     "statecode@OData.Community.Display.V6.FormattedValue": "Active",
     "statecode": 0,
     "caseorigincode@OData.Community.Display.V6.FormattedValue": "Email",
     "caseorigincode": 5,
     "title": "This is test case",
     "prioritycode@OData.Community.Display.V6.FormattedValue": "Normal",
     "prioritycode": 5,
     "ticketnumber": "CAS-06055-Q0B6F9",
     "createdon@OData.Community.Display.V6.FormattedValue": "10/09/2020 13:47",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-10T13:47:04Z",
     "incidentid@odata.type": "#Guid",
     "incidentid": "d976ea6b-6cf9-ea66-a967-000d9a7fcd6e",
     "primarycontactid": {
     "@odata.type": "#Microsoft.Dynamics.CRM.contact",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/contacts(ddd6b4ae-77f9-ea66-a967-000d9a7fcd6e)",
     "@odata.editLink": "contacts(ddd6b4ae-77f9-ea66-a967-000d9a7fcd6e)",
     "fullname": "Test contact",
     "contactid@odata.type": "#Guid",
     "contactid": "ddd6b4ae-77f9-ea66-a967-000d9a7fcd6e"
     },
     "Incident_Emails": [
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.email",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/emails(6d67edaa-66f9-ea66-a967-000d9a7f5595)",
     "@odata.etag": "W/\"9949576\"",
     "@odata.editLink": "emails(6d67edaa-66f9-ea66-a967-000d9a7f5595)",
     "createdon@OData.Community.Display.V6.FormattedValue": "10/09/2020 13:08",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-10T13:08:07Z",
     "description": "test email about something"
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.email",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/emails(a6dc595d-09f4-ea66-a967-000d9a7f5595)",
     "@odata.etag": "W/\"9949575\"",
     "@odata.editLink": "emails(a6dc595d-09f4-ea66-a967-000d9a7f5595)",
     "createdon@OData.Community.Display.V6.FormattedValue": "11/09/2020 08:31",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-11T08:31:25Z",
     "description": "another test email about something"
     }
     ],
     "Incident_Annotation@odata.type": "#Collection(Microsoft.Dynamics.CRM.annotation)",
     "Incident_Annotation": [
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.annotation",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/annotations(54604cbf-efba-69cb-997d-bc0adb9f6e09)",
     "@odata.etag": "W/\"9977544\"",
     "@odata.editLink": "annotations(54604cbf-efba-69cb-997d-bc0adb9f6e09)",
     "createdon@OData.Community.Display.V6.FormattedValue": "12/09/2020 11:54",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-12T11:54:56Z",
     "notetext": "a test note about something"
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.annotation",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/annotations(ec69059b-9d90-cb96-9960-cf697469ff6b)",
     "@odata.etag": "W/\"9949596\"",
     "@odata.editLink": "annotations(ec69059b-9d90-cb96-9960-cf697469ff6b)",
     "createdon@OData.Community.Display.V6.FormattedValue": "12/09/2020 11:49",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-12T11:49:12Z",
     "notetext": "This is a note text again"
     }
     ],
     "subjectid": {
     "@odata.type": "#Microsoft.Dynamics.CRM.subject",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/subjects(4a49aa94-cef6-ea66-a967-000d9a7fcd6e)",
     "@odata.editLink": "subjects(4a49aa94-cef6-ea66-a967-000d9a7fcd6e)",
     "title": "a subject",
     "subjectid@odata.type": "#Guid",
     "subjectid": "4a49aa94-cef6-ea66-a967-000d9a7fcd6e"
     }
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.incident",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/incidents(006ef5b7-e0f4-ea66-a967-000d9a7fcd6e)",
     "@odata.etag": "W/\"9949066\"",
     "@odata.editLink": "incidents(006ef5b7-e0f4-ea66-a967-000d9a7fcd6e)",
     "statecode@OData.Community.Display.V6.FormattedValue": "Active",
     "statecode": 0,
     "title": "This is test case 2 which has NO notes (Incident_Annotation) and NO emails (Incident_Emails)",
     "prioritycode@OData.Community.Display.V6.FormattedValue": "Normal",
     "prioritycode": 5,
     "ticketnumber": "CAS-06059-R5Z6Y0",
     "createdon@OData.Community.Display.V6.FormattedValue": "10/09/2020 11:32",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-10T11:32:55Z",
     "incidentid@odata.type": "#Guid",
     "incidentid": "006ef5b7-e0f4-ea66-a967-000d9a7fcd6e",
     "Incident_Emails": [],
     "Incident_Annotation": []
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.incident",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/incidents(e776cdbe-76f6-ea66-a967-000d9a7fcd6e)",
     "@odata.etag": "W/\"4697474\"",
     "@odata.editLink": "incidents(e776cdbe-76f6-ea66-a967-000d9a7fcd6e)",
     "description": "Dynamics",
     "statecode@OData.Community.Display.V6.FormattedValue": "Active",
     "statecode": 0,
     "title": "This is test case 3 which has notes (Incident_Annotation) and NO emails (Incident_Emails)",
     "prioritycode@OData.Community.Display.V6.FormattedValue": "Normal",
     "prioritycode": 5,
     "ticketnumber": "CAS-06054-Y9P0R0",
     "createdon@OData.Community.Display.V6.FormattedValue": "10/09/2020 11:41",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-10T11:41:17Z",
     "incidentid@odata.type": "#Guid",
     "incidentid": "e776cdbe-76f6-ea66-a967-000d9a7fcd6e",
     "Incident_Emails": [],
     "Incident_Annotation": [
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.annotation",
     "@odata.id": "https://demodata.crmdemo.dynamics.com/api/data/v9.6/annotations(cb0d9f99-a7d0-0994-99fb-97664a97c094)",
     "@odata.etag": "W/\"4697469\"",
     "@odata.editLink": "annotations(cb0d9f99-a7d0-0994-99fb-97664a97c094)",
     "createdon@OData.Community.Display.V6.FormattedValue": "10/09/2020 11:51",
     "createdon@odata.type": "#DateTimeOffset",
     "createdon": "2020-09-10T11:51:37Z",
     "notetext": "test notes",
     "_objectid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": "objectid_incident",
     "_objectid_value@Microsoft.Dynamics.CRM.lookuplogicalname": "incident",
     "_objectid_value@odata.type": "#Guid",
     "_objectid_value": "e776cdbe-76f6-ea66-a967-000d9a7fcd6e",
     "annotationid@odata.type": "#Guid",
     "annotationid": "cb0d9f99-a7d0-0994-99fb-97664a97c094",
     "objecttypecode@OData.Community.Display.V6.FormattedValue": "Case",
     "objecttypecode": "incident"
     }
     ]
     }
    ]

     

     

  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @dan92,

     

    Thanks for your instance, I create a Flow and export it as a zip file, you can download it and import it into your Flow to test.

    The key step is to split the notes and Emails arrays from the original object, then store the attribute values you want into a new array, convert the new array into a string, and then build a new object.

    There is the final output:

    Screenshot 2020-09-21 150201.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • dvn92 Profile Picture
    8 on at

    @v-litu-msft sorry for the delay but I wanted to say thank you as this solution works perfectly! I really appreciate your help.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard