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 Apps / Update dates of all ro...
Power Apps
Unanswered

Update dates of all rows in PowerApp

(1) ShareShare
ReportReport
Posted on by 102

Hi,

my sharepoint data is:

TaskPhaseIDTaskNameIDStartDateDurationEndDate
1100110/1/2023210/3/2023
1100210/3/2023310/6/2023
1100310/6/2023110/7/2023
2200410/7/2023110/8/2023
2200510/8/2023210/10/2023
2200610/10/2023110/11/2023
2200710/11/2023310/14/2023
2200810/14/2023410/18/2023
2200910/18/2023110/19/2023
3301010/19/2023110/20/2023
3301110/20/2023210/22/2023
3301210/22/2023110/23/2023
3301310/23/2023310/26/2023

 

In powerapp, I have the following fields.
PowerApp Field Sharepoint column name
popupStartDate_1 StartDate
popupDuration_1 Duration
popupEndDate_1 EndDate

 

in the power app, if i set the start date of the first row or any row and click the update button (btnsubmit), the code should update all the following rows of Gallery.Selected as the table above. 

EndDate is = StartDate + Duration

EndDate of a row is the StartDate of the next row.

Similarly changing the duration of any row should also update the dates of the following rows.

How can I acheive this? I tried using forAll and patch but it is not working.

 

Thanks

Categories:
I have the same question (0)
  • M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @muzzamal ,

    Try Like This ,

    ForAll(
     Filter(YourSPList, TaskPhaseID >= Gallery.Selected.TaskPhaseID),
     Patch(
     YourSPList,
     ThisRecord,
     {
     StartDate: /* logic to calculate new start date based on previous row's EndDate */,
     EndDate: DateAdd(StartDate, Duration, Days)
     }
     )
    );

    Fuel our success! 🚀 Give a thumbs up and click 'Solution Accepted' to supercharge our community. Your actions speak volumes!
    Warm regards,
    Muhammad Ali

  • muzzamal Profile Picture
    102 on at

    Patch(
    ProgressTracker,
    tasksGallery.Selected,
    {
    Duration: Value(popupDuration_1.Text),
    StartDate: popupStartDate_1.SelectedDate,
    EndDate: popupEndDate_1.SelectedDate
    }
    );

    // Create a collection of subsequent rows to update
    ClearCollect(
    RowsToUpdate,
    Filter(
    ProgressTracker,
    TaskPhaseID = tasksGallery.Selected.TaskPhaseID &&
    Created > tasksGallery.Selected.Created
    )
    );

    // Update subsequent rows based on Created date and store in a collection
    ClearCollect(
    UpdatedRows,
    ForAll(
    RowsToUpdate,
    {
    ID: ThisRecord.ID,
    StartDate: DateAdd(tasksGallery.Selected.EndDate, 1, TimeUnit.Days),
    EndDate: DateAdd(
    DateAdd(tasksGallery.Selected.EndDate, 1, TimeUnit.Days),
    ThisRecord.Duration,
    TimeUnit.Days
    )
    }
    )
    );

    // Patch the updated collection back to the data source
    ForAll(
    UpdatedRows,
    Patch(
    ProgressTracker,
    LookUp(ProgressTracker, ID = ThisRecord.ID),
    {
    StartDate: ThisRecord.StartDate,
    EndDate: ThisRecord.EndDate
    }
    )
    );

    This is updating the first row only. code keeps running but no date is changed after the first one

  • M_Ali_SZ365 Profile Picture
    1,110 on at

    @muzzamal ,

    Try This code let me 

    // Assume StartDate has been set for a row and we need to update subsequent rows
    // Create a variable to hold the initial start date
    Set(varStartDate, Gallery.Selected.StartDate);
    
    // Update subsequent rows
    ForAll(
     Filter(YourSPList, TaskPhaseID = Gallery.Selected.TaskPhaseID && ID > Gallery.Selected.ID),
     Patch(
     YourSPList,
     LookUp(YourSPList, ID = ThisRecord.ID),
     {
     StartDate: varStartDate,
     EndDate: DateAdd(varStartDate, ThisRecord.Duration, Days)
     }
     );
     // Update varStartDate for the next iteration
     Set(varStartDate, DateAdd(varStartDate, ThisRecord.Duration, Days))
    );

    Fuel our success! 🚀 Give a thumbs up and click 'Solution Accepted' to supercharge our community. Your actions speak volumes!
    Warm regards,
    Muhammad Ali

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 316 Most Valuable Professional

#2
11manish Profile Picture

11manish 242

#3
Valantis Profile Picture

Valantis 198

Last 30 days Overall leaderboard