i m trying to loop through all the day of the week and also loop through all project and trying to insert one row for each. So for 7 days of the week and 5 project. I would need to insert 35 records , user name , date , hours and project name
ForAll(DaysOfWeek,
ForAll(Projects,
{
// Calculate the current date and hours based on the day of the week
Set(CurrentDate, DateAdd(SelectedDate, Switch(
DaysOfWeek[Result],
"Sunday", -1,
"Monday", 0,
"Tuesday", 1,
"Wednesday", 2,
"Thursday", 3,
"Friday", 4,
"Saturday", 5
), Days)),
Set(CurrentHours, Switch(
DaysOfWeek[Result],
"Sunday", SundayHours.Text,
"Monday", MondayHours.Text,
"Tuesday", TuesdayHours.Text,
"Wednesday", WednesdayHours.Text,
"Thursday", ThursdayHours.Text,
"Friday", FridayHours.Text,
"Saturday", SaturdayHours.Text
));
// Check if a record already exists in the 'TimeTracker Report'
Set(ExistingRecord, LookUp(
'TimeTracker Report',
UserName = UserFullName && Date = CurrentDate && ProjectName = Project.Name
));
// If no record found, insert a new record; otherwise, update the existing record
If(
IsBlank(ExistingRecord),
Patch(
'TimeTracker Report',
Defaults('TimeTracker Report'),
{
Title: "Test",
UserName: UserFullName,
ProjectName: Project.Name,
Date: CurrentDate,
Hours: Value(CurrentHours)
}
),
Patch(
'TimeTracker Report',
ExistingRecord,
{
Title: "Test",
Hours: Value(CurrentHours)
}
)
)
}
)
)
Cna you please correct this query? I m gettting Forall function is having invalid argument