cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
Dual Super User III
Dual Super User III

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!

Highlighted
Frequent Visitor

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.

Highlighted
Dual Super User III
Dual Super User III

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!

Highlighted
Community Support
Community Support

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
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Top Kudoed Authors
Users online (8,757)