cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Julian1
Level: Powered On

Update specific Item with dynamic position in Array according to Inputdata

Hi, 

 

is there a way to Update the following array:

 

[
  {
    "Name": "Max Muscle",
    "Email": "maxmuscle@muster.com",
    "Course 1": "x",
    "Course 2": "o"


  },
  {
    "Name": "Michael Johnson",
    "Email": "mj@google.com",
     "Course 1": "o",
    "Course 2": "o"
  

  },
  {
    "Name": "Dummy Dummy",
    "Email": "dummy@dummy.com",
     "Course 1": "x",
    "Course 2": "x"

  }
]

with this Input-data:

[
  {
     "version": "1.17",
    "userEmail": "knightright@sin.com",
    "userName": null,
    "sendDate": "2019-06-28T21:15:47.6208279Z",
    "receivedDate": "2019-06-28T21:15:48.0330384Z",

    "title": "Form1",
    "data": {
      "DataRecord": {
        "Name": "Michael Johnson",
		"Email": "mj@google.com",
		
      },
		"Username": "Michael Johnson",
		"Course 1": "o",
		"Course 2": "o""
      }
  }
]

so the specific array where the "Name" has the value "Michael Johnson" needs to be updated according to the inputdata (marked in pink). The thing is: It cannot be done by using [1] index, because the position of the item in the array is dynamic and can be also the third or first position.

 

Is there any way to solve this problem?

Thank you for your help!


Regards Julian

4 REPLIES 4
Dual Super User
Dual Super User

Re: Update specific Item with dynamic position in Array according to Inputdata

Hi @Julian1 

 

From what I understand you want to find an element in an array and update another array based on that? Plase have a look at the screenshot below:arrays.png

 

Here I am looking for the name and email in the array and if that is a match, i am extracting the stuff and populating another array. 

 

Expression used in the condition:

 

items('Apply_to_each')['Name']
items('Apply_to_each')['mj@google.com']

Expression used in append array variable:

items('Apply_to_each')['Name']
items('Apply_to_each')['Course 1']
items('Apply_to_each')['Course 2']

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Julian1
Level: Powered On

Re: Update specific Item with dynamic position in Array according to Inputdata

Thank for your help. Sadly its the other way around. I need the second Code ("InputData") as the Inputdata for the first array... I need a function so search in the first array for the right position.

Dual Super User
Dual Super User

Re: Update specific Item with dynamic position in Array according to Inputdata

Hey @Julian1 

 

You could just flip that around then. All you have to do is access the field from the data source and then look for that in the target and update the rest (just as I showed in the flow)

 

Please let us know if you face any issues with that. 

 

Hope this helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Community Support Team
Community Support Team

Re: Update specific Item with dynamic position in Array according to Inputdata

Hi @Julian1 ,

 

Please try to use the following method.

  • Use Parse JSON action to parse the input data and the array separately.
  • Determines whether UserName in the Input-data is equal to Name in the array.
  • If they are equal, the specified property is updated. If they are not equal, the element is directly appended to the array.

 

You could download the attachment I uploaded and import it to configure Flow.

Note that this method currently works for input-data with only one element in this array.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,768)