Hi PowerUsers,
I want to create a hierarchical JSon in Flow which should hold a parent child format in it.
I am fetching the source data from SQL which needs to be transformed into this Json format, then this JSon will be passed to an Organogram which is being created on javascript.
Here is a sample of what i am trying to achieve.
{
'name': 'Lao Lao',
'title': 'general manager',
'children': [
{ 'name': 'Bo Miao', 'title': 'department manager' },
{ 'name': 'Su Miao', 'title': 'department manager',
'children': [
{ 'name': 'Tie Hua', 'title': 'senior engineer' },
{ 'name': 'Hei Hei', 'title': 'senior engineer',
'children': [
{ 'name': 'Pang Pang', 'title': 'engineer' },
{ 'name': 'Xiang Xiang', 'title': 'UE engineer' }
]
}
]
},
{ 'name': 'Hong Miao', 'title': 'department manager' },
{ 'name': 'Chun Miao', 'title': 'department manager' }
]
}
In SQL, I have Employee ID and ParentPositionID in the same table which specifies who reports to whom.
The challenge is to transform the SQL data into this JSon format to "Nth" level.
I do not know how many levels of hierarchy could be there.
I need to create a recursion in flow which goes to the "Nth" level of hierarchy and on the same time the load/computation time of this flow should be as less as possible because this JSon will be associated with a Javascript which will be displaying the data retrieved form JSon on runtime.
I have tried nested looping but it takes too much of time for calculating even 10 employees data.
I am looking for a fast and accurate solution for this problem.
What can be the best possible solution for this ?
I'm looking forward to usual helpful responses.
Best Regards,
Ali Nawaz
Hi @Anonymous
Very interesting question you posted and a challenging one.
PowerAutomate connectors can get the results (Collection), then iterate the loop or some situation we can use Select action step to filter the contents. My view is you probably could build this in flow but might have performance issues.
Did you thought about generating this JSON from SQL itself? Not sure how fast that will be.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogHi @abm yes i saw the json converter function of SQL but it doesn't suffice the need.
It doesn't create the nested json which we are looking for.
I am looking for an approach which is time efficient and gives nested json.
I do not mind going outside the domain of Flow/SQL/PowerApps, just looking for a good workaround for this challenge.
Thanks,
Best Regards
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
31 | |
28 | |
27 | |
21 | |
10 |