cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jasmine2020
Microsoft
Microsoft

How can I update nested fields using a Logic App

**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"}

 ]

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

5. 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"

}

]

 

 

jasmine2020_0-1597268621633.png

 

jasmine2020_2-1597268657049.png

 

jasmine2020_3-1597268689062.png

jasmine2020_5-1597268718749.png

 

 

 

 

 

 

 

 


Error I have:

 

 

 

jasmine2020_6-1597268755279.png

 

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)

 

jasmine2020_7-1597268788278.png

 

 

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

 

jasmine2020_8-1597268813995.png

 


(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.

4 REPLIES 4
abm
Super User III
Super User III

Hi @jasmine2020 

 

 

Your second for each loop I can see you append to array and immediately create or update the document. Is that correct? I can see here your array is going to append 20 times and each time it is going to create or update operation?

 

image.png



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Hi @abm 

 

I am not sure if I am doing this right. For every document in the Feedback array, I wish to loop over this and update the contents within it.

 

 

             Feedbacks: 

                        [

                               {

                                      "id":"1234"

                               }

                       

                              {

                                     "id":"5678"

                              }

                        ]

 

so for every document within this Feedbacks array, I wish to then update the nested fields within it

 

 

 Inside of the "id":"1234":

                  

 

                       "id":"1234"

                       "Features":

                                            [

                                             {

                                     

                                                "id": "i wish to update"

                                                "state": "i wish to update"   

                                             }

                                          [

 

 

I figured I can do a for each loop to iterate over the feedbacks document and then

use a variable to replace certain fields I need to update

abm
Super User III
Super User III

Hi @jasmine2020 

 

Couple of issues we resolved

 

1. JSON schema validation failed due to null. We resolved this changing the parse schema validation to accept string or null.

2. Next we iterate the ID and extract the id value using another Parse JSON

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Thank you so much. I am working on this now

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,143)