Hi team,
I have a TimeOff application that add requests in date range (VacationRequest a SP list), the app allows to enter either 8 or 4 hrs per off day request. An example of the list is below:
VacationRequest:
Title From To Days Hrs
Peter 2022-10-05 2022-10-11 5 40
Tony 2022-10-28 2022-10-28 0.5 4
Henry 2022-10-25 2022-10-26 1.5 12
Resource Managers will pull a request and either Approve or Reject the request, the approve button generate the DetailedVacation collection and will update the SP TimeOff Calendar with the day and Time approved as follows:
Set(selectedItem,ThisItem);
ClearCollect(
DetailedVacation ,
AddColumns(
FirstN(
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],
DateDiff(selectedItem.From, selectedItem.To, Days) + 1),
"Day", "Day " & (Value + 1),
"Date", DateAdd(selectedItem.From, Value, Days),
"Type",selectedItem.TimeOffType.Value,
"Hours","8",
"Person",Title));
// remove weekend and holiday from employee calendar
RemoveIf(DetailedVacation ,Weekday(Date) = 1 Or Weekday(Date) = 7 Or !IsBlank(LookUp(HolidayCalendar,Text(holWorkDate,DateTimeFormat.ShortDate) = Text(Date,DateTimeFormat.ShortDate)
)));
Correct generated collection for Peter's request:
DetailedVacation
Person From Hours
Peter 2022-10-05 8
Peter 2022-10-06 8
Peter 2022-10-07 8
Peter 2022-10-10 8
Peter 2022-10-11 8
Wrong generated collection for Tony's request, it should say 4 hrs:
DetailedVacation
Person From Hours
Tony 2022-10-28 8
Wrong generated collection for Henry's request, it should say 8 and 4 hrs:
DetailedVacation
Person From Hours
Henry 2022-10-25 8
Henry 2022-10-26 8
I would appreciate you can help me to correct or re-write above code.

Report
All responses (
Answers (