I thought I saw this before, but after an hour of looking, I cant find it. Simply put. I have two arrays, with a common DocumentID. I just need to JOIN them goether ON DocumentID (using SQL lingo)
Array1:
[
{
"DocumentID": 1265,
"PartNumber": "510009",
"Rev": "1",
"Description": "KBOV HANDLE BRACKET ASSEMBLY"
},
{
"DocumentID": 2338,
"PartNumber": "KBV8-N-FW",
"Rev": "0",
"Description": "KBV8-N-FW GENERAL ARRANGEMENT & BOM"
},
{
"DocumentID": 5522,
"PartNumber": "213155",
"Rev": "0",
"Description": ".125 X .50 DOWEL PIN CS"
}
]
Array2:
[
{
"DocumentID": 1265,
"Comment": "."
},
{
"DocumentID": 2338,
"Comment": "Exploded view still WIP."
},
{
"DocumentID": 5522,
"Comment": "."
}
]
This is what I want:
[
{
"DocumentID": 1265,
"PartNumber": "510009",
"Rev": "1",
"Description": "KBOV HANDLE BRACKET ASSEMBLY",
"Comment": "."
},
{
"DocumentID": 2338,
"PartNumber": "KBV8-N-FW",
"Rev": "0",
"Description": "KBV8-N-FW GENERAL ARRANGEMENT & BOM",
"Comment": "Exploded view still WIP."
},
{
"DocumentID": 5522,
"PartNumber": "213155",
"Rev": "0",
"Description": ".125 X .50 DOWEL PIN CS",
"Comment": "."
}
]
I'm sure there is a simple expression for this.
Hi @martinav
Yes , even i am not fully like my approach but as of now cant think of any other method, as we are merging two multi filed JSON :(. i can tell its complex in C# too ;).
@DeepakS ,
A little update. I added an additional source to merge. Thus, I'm merging three arrays together. Its as "simple" (after getting all of the syntax, language and usage correct) as adding another nested loop. The disadvantage to this is it took over 2 minutes to run this part of the flow with 6 items in the items being acted upon. Its only a once a day notification, so PA isnt waiting on it. But, it is something to keep in mind. Even two loops deep with 6 items tool over a minute to execute. This will never be a large number. I doubt it ever gets over 10 items, but that is something to consider with this method. Of course, I'm not sure there is another method out there. This is by far the simplest I saw. Props to @DeepakS for this!
@DeepakS ,
Huh, well, lookie there. That works. I was dancing around this for hours. Looks like you saved me a few more.
Nice job!
Hi @martinav
Yes you can export/import. to import my flow just download it as it is and import here is an screen:
@DeepakS ,
Oh, I most certainly have not resolved my issue. I thought it would be easy to just make a SQL View, because it is a simplified form of a view I already have. However, that also is failing, and I have beat on it for several hours. Side-by side comparison with an existing, and its been expressly perfect, but does not work. I'm about to bail on this.
However, I was surprised by your post. Of course, I'm confronted once again with an unknown, and unintuitive task... which is how the hello do you import a flow from what you have given. Especially since I had no idea that you could even export them.
I will try it if this task is not a multi-hour challenge.
Any direction on where to go to do this?
Thank you.
Hi @martinav
I am not sure if you have already solved your issue but i find this interesting and thought of spending some time on it. i finally able to make it work (dont think its a best solution and i may need to work on improving it) but its working.
i uploaded working flow at github:
https://github.com/DeepakS22/DPowerAutomate/blob/master/MergeJSON_20200327174700.zip
Have a look and let me know if that helps.
Regards,
Hi!
I understand your concerns: PowerApps with its own language, Power Automate too, ODATA... sometimes is a bit frustrating... The dream of zero code is still a dream, even thought Microsoft is putting lots of efforts to help us
Hope your story will have a happy ending... please let us know your progress on your challenge
Thanx!
You have NO idea how much I appreciate the help of others here. I am working through this solution. I think of myself as pretty savvy with this type of thing, but I will tell you. The absolute convolution of how many things work in this system is very troubling. I am completely dumbfounded on how people come up with solutions like this. Even with the answer right in front of me, and using the SAME names, etc, it is still very difficult to get everything right to make it work. I'm still working on it, and will report back when its working. I need to implement this solution to several flows.
Its funny, because to do the exact same thing in powerapps is also a trick. I can get my head around it better, but it took a while to figure out the ForAll() statement. What is sooo simple in SQL (JOIN statement). I still have to study what I did on other apps in order to use it again, but I have a solution on that side of the power platform. I do find it interesting that these tools are designed as "code free", but when it comes down too it, you have to know more different types of code in order to get things to work the way you want. If you are super simple, you can get out of it, but if you do anything of real depth, then you have to figure out MANY different languages. ODATA, JSON, and Expressions (flow) just to name a couple. Doing the same type of thing in PowerApps compared to Flow is an entirely different animal and requires very different knowledge.
Sorry, I'm whining a bit. I'll report on progress.
WDL limitations are usually frustrating.
I have managed to join elements from two different arrays (lets call them 'myInput1Array' and 'myInput2Array') when both elements shared a common property value, but it is very time consuming both on the design and on the performance.
So, you need to initialize a third array variable, let's call it 'myOutputArray', leave it empty for the moment.
Now, you use an Apply to each and assign as its input 'myInput1Array'
Inside the Apply to Each, you add a Filter Array and assign as its input 'myInput2Array', try to match common property value from current Apply to each iteration. Now you make sure a single match, if so, Append to array variable, name 'myOutputArray', value:
setProperty(setProperty(setProperty(json('{}'),'Property1FromArray1Name','Value'),'CommoProperty','Value'),Property1FromArray2Name','Value')
So, property values from myInput1Array are obtained from
items('Apply_to_each')
And, property values from myInput2Array are obtained from
first(body('Filter_array'))
As I mentioned, very inneficient but saved my day
Hope this helps