Update existing array items from another array
Options
espptyltd
Member ✭
I'm trying to update an existing array's items with results from a separate array, matching based on a value match between the two arrays.
The first screenshot (premergedJSON) is the data structure prior to the merge, and the second screenshot (PostMergedJSON) is what I'd like the data to be structured as after the merge.
The key that I'm trying to match on in the first array is "key" and the key from the second array to match on is "field_id". They both have the same value, and therefore I want the content from each matched array item to contain the contents from both arrays.
Thanks for any guidance on how to achieve this.
[premergedJSON.png][PostMergedJSON.png]
The first screenshot (premergedJSON) is the data structure prior to the merge, and the second screenshot (PostMergedJSON) is what I'd like the data to be structured as after the merge.
The key that I'm trying to match on in the first array is "key" and the key from the second array to match on is "field_id". They both have the same value, and therefore I want the content from each matched array item to contain the contents from both arrays.
Thanks for any guidance on how to achieve this.
[premergedJSON.png][PostMergedJSON.png]
Comments
-
Hi, Damien! Neat problem! Thinking it could save you some time, I made a loom video that walks through this process: https://www.loom.com/share/31aa1e09f29f4c3fa4ee0981de95e9bd
-
Firstly, thank you so much Ray Deck for your incredibly detailed response and putting the video together. It's community members like you that ensure us new comers can get the most out of a platform such as Xano.
I tried implementing your suggestions, however my combined array always comes out empty. I've gone over it many times, but can't quite figure out what I'm doing wrong.
Attached is my config :[MergedArrayConfig.png]Thank you for any further guidance.
FYI : The GetValuesArray output is actually named result_1 in the output screenshot from my first post ( to just confuse of course! ) -
Managed to fix it!
For some reason the item and item2 in the Conditional if were set as text. When I changed it to var the comparison started working correctly.
Again, thanks for your guidance and response.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback