creating a web template to represent entity data in tree structure ..
to get n no.of child hierarchy need to loop in javascript fuction .. where my entity has data paret column and Child column..
how to loop entity data in javascript function.
Either the way in the link Oliver provided or something similar.
The example in the link is where you setup a web template and then use ajax to call a page based on that template - if you want to just put it in the Web Template behind your page rather than calling the other page it is very similar except where they dump out the JSON (about line 16 in the image in the link) you just do a
<script> var myResult = { "results": ...output here ......} </script> then when the template renders you just access myResult.
The approach depends on what you may need - e.g. are you going to want to load the JSON from the fetchxml multiple times (or need to re-fetch with a condition based on some user input) when on the page or do you just need it there at the web page load.
something that I like to do is create a web template that will retrieve my data in a JSON format, you can follow the steps from this article: https://www.inogic.com/blog/2020/11/use-of-json-type-web-templates-in-powerapps-portals/
Thank you Fubar for your response.
in my entity having data like.
Entity | treedata | ||
Columns | Parent | child | |
a | |||
b | |||
c | |||
a | aa | ||
a | aaa | ||
b | bb | ||
c | cc | ||
aa | aa1 | ||
aa | aa2 | ||
bb | bb1 | ||
c | ccc |
i want to represent like:
to get this... i am fetching my entity data
through fetchxml in liquid code
To answer properly need to better understand what you are doing (provide some of your code etc).
Usually you run a fetch query in Liquid and then loop the results (in liquid) and write an array, Object, or JSON object as a JS variable. Then in JS you just access the variable you created.
Accessing the data in the JS variable would be a for, forEach, via Keyword, for key in, or in JQuery $.each() etc depending on how you approach it
Lucas001
60
Super User 2025 Season 1
Fubar
55
Super User 2025 Season 1
surya narayanan
35