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 / Updating another Share...
Power Automate
Suggested Answer

Updating another Sharepoint List when an item is created

(1) ShareShare
ReportReport
Posted on by 438
This is probably a simple one which unfortunately I cannot get my head around :(
I have a SharePoint list(Events) which records events and movements of our team, whether that be holidays, training, absence etc. The second SharePoint list (Totals) tallies the totals up for each team member, ie how many days holiday each individual has taken. I want the flow to automatically add the correct numbers of days taken to the total field for the relevant person. ie when I work from home for 2 weeks it adds 10 days (Taking off the weekends) to my total.
 
To achieve this I used copilot to suggest a flow and I have started with the "When an item is created" trigger, then I have the "Get Items" action for the totals SP list. Although I though I would need to "Get Items" from the events list, or even both. Here is where it all falls apart as I haven't any idea what to do.
 
 
Categories:
I have the same question (0)
  • Building with Why Profile Picture
    351 Super User 2025 Season 2 on at
    Your instincts are right on. 
     
    You need a Get Items from the Events filtered by the employee and an Active status if that matters.
     
    You can use a length(outputs('Get_items')?['body/value']) to count the records returned and write that into the Employee Totals for that employee.
     
    Unless you have lookup columns with relationships between the Events and the Totals you will need to do a Get Items on the Totals filtered by the employee as well to find the Employee record.  You can use outputs('Get_items_2')?['body/value']?[0]?['Id'] to retrieve the first record of that Get Items. (adjust as necessary for your flow)
  • Suggested answer
    The Texan Integrator Profile Picture
    11 on at
    Seeking a bit more information and offering a caution...
     
    Questions:
    1.) Do you have a unique identifier for each employee in both lists? If so, are those unique identifiers the same name and same value in both lists? This will play into the 'Get items' later.
    2.) Do you already have a calculated column in the Events list to give you the total days (DateDif) between the [Start date] and [End date] of that discrete event? This will give you an integer with the 'TotalDays' for that event.
     
    Caution:
    I would caution you against using an automated (based on an event like an item being created) flow versus using a scheduled flow. If a line item in your Events list gets deleted, your Totals list will not be updated to reflect the correct number of days for each employee.
     
    Suggestion:
    1.) Create a Scheduled Flow based on a timeline that makes sense for your environment (once per hour, once per day, etc.)
    2.) Assuming you have the same unique identifier for each employee across both lists, start with a 'Get items' action that will return the Totals SharePoint list. We'll name it 'Get Totals List Items'
    3.) Initialize an integer variable
    4.) Add an 'Apply to each'. We'll name it 'Apply to each employee'. In the 'Select an output...' field, insert dynamic content of 'value' from the 'Get Totals List Items'.
    5.) Insert another 'Get items' action to return the Events list with a filter query that returns only records with a matching employee ID (dynamic content from the previous 'Get items'). We'll name it 'Get Events List Items'
    6.) Create a 'Set variable' where you reset the counter variable (from step 3) to 0. Move this action above the second 'Get items' but still within the 'Apply to each employee' loop
    7.) Add another 'Apply to each'. We'll name it 'Apply total from each event'. In the 'Select an output...' field, insert dynamic content of 'value' from the 'Get Events List Items'.
    8.) Insert 'Increment variable' using the same initialized variable from above and insert the dynamic content of the (assumed to exist) 'TotalDays' field from the 'Apply total from each event' step. The hover-over text will look something like this: items('Apply_total_from_each_event')?['TotalDays']
    9.) Just outside the 'Apply total from each event' loop, add a SharePoint 'Update item' action and select the Totals SharePoint list. In the 'Id', select the matching 'Id' field from 'Get Totals List Items' step. In your 'Total Days' field, insert the dynamic content of your variable.
     
    All this assumes you will have the same employees in one list as you do the other. No error checking has been built into this flow. It may be something to consider should there be an employee in one list but not the other.
     
    I've checked the flow with some dummy data in my sandbox, so I'm happy to help troubleshoot if this goes awry.
     
    - Jerry
     
  • nshaw75 Profile Picture
    438 on at
    Hi Jerry,
     
    Many thanks for such a comprehensive guide, this is exactly the type of help I need as I do struggle.  Apologies for the late reply I was pulled here there and everywhere last week.
     
    I have followed the instructions and my flow is failing. 
    I think I have done the flow correctly 

     
    I would guess I have gone wrong at the final hurdle, the error message shows the Apply to each Employee action failing saying 'Get Events list items failed

    For some reason the value I have calculated in the SP list is not showing in any of the dynamic content. Not sure whether this is the problem.
  • The Texan Integrator Profile Picture
    11 on at
    Please post a screenshot of the error message (from the failed test) and the expanded flow (in edit mode).
     
    Happy to help troubleshoot via Teams, if you need.
     
    - Jerry

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard