Update existing array items from another array

Options
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]

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    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
  • espptyltd
    espptyltd Member
    Options
    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! )
  • espptyltd
    espptyltd Member
    Options
    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.