web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Update specific Item w...
Power Automate
Unanswered

Update specific Item with dynamic position in Array according to Inputdata

(0) ShareShare
ReportReport
Posted on by 6

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

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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 Profile Picture
    6 on at

    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.

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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!

  • v-bacao-msft Profile Picture
    on at

    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,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard