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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Update one sharepoint ...
Power Automate
Unanswered

Update one sharepoint list column based on another lists data

(0) ShareShare
ReportReport
Posted on by 135

I've added a new column called "City" to _MasterList. 

 

I have another list called _BranchList, which has a column named "City" in it.

 

The _MasterList already references _BranchList using the _BranchList.ID column.

 

I need to create a script which matches _MasterList.BranchList.ID with _BranchList.City and then returns the city to _MasterList.City

 

Here is what I have:

_MasterList:

ID_BranchList.IDStateZipCity
14TX73245 
23AZ81245 
31KS67592 

 

_BranchList:

IDStateZipCityPOC
1KS67592FlatLandJohn
2TX79395DallasDoe
3AZ81245SunBurntLives
4TX73245PoDunkNot

 

 

Here is what I need:

_MasterList:

ID_BranchList.IDStateZipCity
14TX73245PoDunk
23AZ81245SunBurnt
31KS67592FlatLand

 

_BranchList:

IDStateZipCityPOC
1KS67592FlatLandJohn
2TX79395DallasDoe
3AZ81245SunBurntLives
4TX73245PoDunkNot

 

Any help is appreciated. 

Categories:
  • vivekpande18 Profile Picture
    894 Super User 2024 Season 1 on at

    Hi @AndrewValenzuel ,

     

    Find below steps to achieve the functionality:

     

    1- Get Master list data & Branch List data.

    vivekpande18_0-1653064621463.png

     

    2- Loop over the values of of Master List

    vivekpande18_2-1653064690248.png

     

    3- Filter the Branch List values based on the lookup column if present in Master list

    vivekpande18_3-1653064779356.png

    From: Values from Branch list

    Left : item()?['ID']

    Right : items('Apply_to_each')?['BranchList']['Id']--->expression might be different in your case based on lookup column internal name.

     

    4- Update City column in Master list

    vivekpande18_4-1653064919036.png

    {
    "__metadata": {
    "type": "SP.Data.MasterListItem"
    },
    "City":"@{body('Filter_array')[0]?['City']}"
    }

     

    This will work for you..

     

    Thanks

    Vivek Pande

     

    If this post helps answer your question, please "Accept as Solution" to help others find it more quickly.

    If you thought this post was helpful, please give it a Thumbs Up.

     

  • AndrewValenzuel Profile Picture
    135 on at

    I will try this out next week.  Thank you for the reply.

     

    That all makes sense to me but I have this one question.  This last line:

    {
    "__metadata": {
    "type": "SP.Data.MasterListItem"
    },
    "City":"@{body('Filter_array')[0]?['City']}"
    }

     

    I'm trying to figure out why the names are the way they are.


    "type": "SP.Data.MasterListItem"  Is this line named this way because the type is SP.: sharepoint , Data.: named because we are sending data,  MasterList: points to the list we are updating Item: because we are singalling that we are updating items per line?

     

    "City":"@{body('Filter_array')[0]?['City']}"  is this line's ('Filter_array')[0] named this way because we are running a for loop and starting at [0]?  If I were to change this to [2] would it then skip the first 3 lines.

     

  • vivekpande18 Profile Picture
    894 Super User 2024 Season 1 on at

    Hi @AndrewValenzuel , 

     

    SP.Data.MasterListItem

    From text above, portion which is bold you will replace it with your actual list name and rest everything will be same. 

    For ex. 

    Your list name : Test, then entity name will come like below

    SP.Data.TestListItem

     

     

    The ListItemEntityTypeFullName property (SP.Data.TestListItem in the previous example) is especially important if you want to create and update list items. This value must be passed as the type property in the metadata that you pass in the body of the HTTP request whenever you create and update list items.

     

    City":"@{body('Filter_array')[0]?['City

     

    Output of filter action will be an array with single object inside it. Like below

    [{City : 'Testcity'...... }]

    So to access the city value, we need to access the object first which is at 0th position inside array and after that we can access City. 

     

    Hope you can relate now. 

     

    Thanks

    Vivek Pande

     

  • JessicaIntact Profile Picture
    2 on at

    Hello, I'm trying to achieve a similar thing  - I'm following your power automate example but  I'm not sure what I should or why I need to complete the 'Headers'. Can I copy it exactly as you have it or should I  be substituting info? 

    I'm also looking to update 3 fields , would appreciate know how to add more I the scrip within the body.

    JessicaIntact_1-1686647965082.png

     

    For background I'm trying to achieve the below. You seem so knowledgeable! Any help/suggestion on how to achieve this would be really appreciated! I'm a new Power Automate User  and no experience in writing scripts 🙂

     

    List A - Stores all Staff/Learners. This list stores Name, Role, Job Title, Business Unit, Team and Product they work on in the business.

     

    List B - This populates once they complete a course and this is a list of achievements. It stores the Name, the Course, Date achieved and I've added additional fields for Business Unit, Team and Product. I would like the BU, TEAM and Product Fields to auto populate with the values against the Learners name in List A so that when the achievements are exported I can pivot and report on achievements by Business unit etc. 

     

    Thank you, 

    Jess 

  • sandeepstw Profile Picture
    312 Moderator on at

    To match the _MasterList.BranchList.ID with _BranchList.City and update the _MasterList.City column accordingly, you can follow these steps:

    1. Get the Items from both Lists:

      • Use SharePoint connector actions to retrieve the items from the _MasterList and _BranchList lists.
    2. Initialize Variables:

      • Add a "Initialize variable" action to create an empty array variable to store the matching cities. Let's call it matchingCities.
    3. Loop through _MasterList Items:

      • Add a "Apply to each" control action to iterate through each item in the _MasterList.
      • Inside the loop, access the current item's BranchList.ID value.
    4. Find the Matching City in _BranchList:

      • Add a "Filter array" action after the loop. Set the "From" field to the _BranchList items.
      • In the "Condition" field, enter item()?['ID'] eq currentItem()?['BranchList.ID'].
    5. Extract the Matching City:

      • Add a "Select" action after the "Filter array" action. Set the "From" field to the output of the "Filter array" action.
      • In the "Map" field, enter the following expression: {'City': item()?['City']}.
    6. Append the Matching City to matchingCities:

      • Add an "Append to array variable" action after the "Select" action. Set the "Name" field to matchingCities.
      • In the "Value" field, enter the output of the "Select" action.
    7. Update _MasterList Items:

      • Add an "Update item" action outside the loop to update the _MasterList items.
      • Set the "List Name" field to _MasterList and specify the item ID you want to update.
      • Set the "Set City" field to the value of the matchingCities variable.
    8. Save and Test the Flow:

      • Save your Power Automate flow and test it with sample items in the _MasterList.
      • Ensure that the matching cities are correctly assigned to the _MasterList.City column.

    By following these steps, you can match the _MasterList.BranchList.ID with _BranchList.City and update the _MasterList.City column accordingly. The flow iterates through each item in the _MasterList, finds the matching city in the _BranchList, and updates the city value in the _MasterList.

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 298 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard