0

Background: I'd like to perform an update on nested fields using the LogicApp

This is what I did:

  1. Ran my query to fetch the documents I need

  2. Create global variable that holds the array that I wish to 'update'

  3. Run for each loop over the first query, parsed the JSON , create a for each loop for

all of the items in the Feedbacks array : 

            [   
                { "id" : "1234"}

            ]
  1. Append the variable that I created with the current item in the loop

  2. Finally update that original feedback array with the updated array that was created in the

   first variable dynamically.

                    "id":"1234"

                    "Features": 

            [  

                     { 

                       "id": "update me"

                       "state": "update me"

                     }

             ]

enter image description here enter image description here enter image description here enter image description here Error I have:

enter image description here

I suppose its placing the array

                         [  
         
                             { 

                               "id": "update me"
                               "state": "update me"
                               

                             }
           
                        ]

inside the

Feedbacks array []

When I am wanting  the items and array that the feedback id is pointing to to be updated within the feedback array, nested in the Features array.

For instance this is the feature container that holds the Feedbacks array (highlighted)

enter image description here

And within the Feedbacks array above, I am wanting to iterate within each of its ids and then update that Features array with what I provided in the variable

enter image description here

(I believe what needs to be updated is being placed in that initialize variable?)

Any advice or suggestion is greatly appreciated. I am a bit stuck on this.

Lynn
  • 2,193
  • 9
  • 14

1 Answers1

1

Unfortunately, I don't have access to Azure Portal at this moment but I can try to give a few suggestions here.

I suppose its placing the array inside the Feedbacks array []

You can check that by opening the Logic app execution block at that current moment and debugging the content. However, what I can see at this moment as a possible issue there is that you need to remove the [ braces when putting the Feedback inside the main object as a property.

enter image description here

And within the Feedbacks array above, I am wanting to iterate within each of its ids and then update that Features array with what I provided in the variable

Ok, so a few things here:

  1. Make sure that the CosmososDB data is consistent in terms of its contents. If your Feedbacks data is saved in the CosmosDB item by item (each item is a separate record), then the same way update should happen. However, if your Feedbacks array is part of some bigger object, than as an update to the CosmosDB you should send the bigger object, containing the Feedbacks array, but not just the Feedbacks array or some part of it.
  2. Make sure you are updating the data using the same Partition Key for the CosmosDB.
Arsen Khachaturyan
  • 6,472
  • 4
  • 32
  • 36