cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Filistyn
Helper V
Helper V

Changing Sharepoint list data based on date

Hello!

 

I have this sharepoint list: 

asd.pngI am saving data by a button (It is not important for my question, just want to cover everything):

Switch(
    typDovolene,
    "Vacation",
    Collect(
        VacationTracker,
        {
            Title: User().Email,
            StartDate: StartDate.SelectedDate,
            EndDate: EndDate.SelectedDate,
            LenghtInDays: Value(lblDaysOfVacation.Text),
            TypeOfVacation: Text(typDovolene),
            DepartmentCopy: Text(
                LookUp(
                    Employees,
                    NameOfEmployee = User().Email
                ).Department
            )
        } 
    ),
    "Overtime",
    Collect(
        VacationTracker,
        {
            Title: User().Email,
            StartDate: StartDate.SelectedDate,
            TypeOfVacation: Text(typDovolene),
            HoursOvertime: drpOvertime.SelectedText.Value,
            DepartmentCopy: Text(
                LookUp(
                    Employees,
                    NameOfEmployee = User().Email
                ).Department
            )
        }
    ),
    "Business Trip",
    Collect(
        VacationTracker,
        {
            Title: User().Email,
            StartDate: StartDate.SelectedDate,
            EndDate: EndDate.SelectedDate,
            LenghtInDays: Value(lblDaysOfVacation.Text),
            TypeOfVacation: Text(typDovolene),
            DepartmentCopy: Text(
                LookUp(
                    Employees,
                    NameOfEmployee = User().Email
                ).Department
            )
        }
    ),
    "Halfday",
    Collect(
        VacationTracker,
        {
            Title: User().Email,
            StartDate: StartDate.SelectedDate,
            TypeOfVacation: Text(typDovolene),
            HalfdayType: drpHalfday.SelectedText.Value,
            DepartmentCopy: Text(
                LookUp(
                    Employees,
                    NameOfEmployee = User().Email
                ).Department
            )
        }
    )
);
Set(
    daysRequested,
    RoundDown(
        DateDiff(
            StartDate.SelectedDate,
            EndDate.SelectedDate,
            Days
        ) / 7,
        0
    ) * 5 + Mod(
        5 + Weekday(EndDate.SelectedDate) - Weekday(StartDate.SelectedDate),
        5
    ) + 1
);

If(typDovolene = "Vacation", Patch(Employees, LookUp(
                    Employees,
                    NameOfEmployee = User().Email
                ), {VacationValue: Value(lblAvaliableDays.Text)}));

Navigate(
    Main,
    Fade
);

There is a column called EndDate and StartDate and the input is from two Date pickers. 

 

I need a code, which will switch a whole row to another sharepoint list called VacationTrackerDone everytime when Today() > EndDate and delete this row from the VacationTracker. Basically just move it from one sharepoint list to another.

I probably know, how to write the code, but I have no idea where to type it.

 

Could someone help?

2 ACCEPTED SOLUTIONS

Accepted Solutions
rubin_boer
Super User
Super User

hi @Filistyn, will you consider power automate for this on a scheduled flow. this way you do not have to do anything (we are lazy). flow can check daily if the condition is true for the list (Endate < Today()) and move those items?

 

Consider this template: Move items from one SharePoint list to another | Microsoft Power Automate and change the start to a scheduled flow.

 

Hope this helps

View solution in original post

Hey, It really worked! Thank you very much

hgfhf.png

 

 

View solution in original post

3 REPLIES 3
rubin_boer
Super User
Super User

hi @Filistyn, will you consider power automate for this on a scheduled flow. this way you do not have to do anything (we are lazy). flow can check daily if the condition is true for the list (Endate < Today()) and move those items?

 

Consider this template: Move items from one SharePoint list to another | Microsoft Power Automate and change the start to a scheduled flow.

 

Hope this helps

View solution in original post

Hey! Gonna check it out and come back with results

Hey, It really worked! Thank you very much

hgfhf.png

 

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,537)