Hi Everyone,
I am creating a Power App that tracks the Attendance status of the Users.
Have 2 Excel sheets or tables for the data.
1. User_Data
2. Attendance_Tracker
The basic idea here is to bulk update records with the Attendance Date and Attendance Status.
The User_Data is the data source for a multi-select gallery that collects the selected records in a collection 'colSelectedData'.
I have a separate section that takes date from a Date Picker and Dropdown for the Attendance Status having 2 options - 'Attended' & 'Not Attended'.
Once I click on Update button, I want the records to be added to the Attendance_Tracker data source/table.
I am using the below query to do so
Set(
varTimeStart,
Now()
);
ForAll(
colSelectedData,
Patch(
Attendance_Tracker,
If(
!IsBlank(
LookUp(
Attendance_Tracker,
'Mail_Id' = ThisRecord.'Mail_Id' && 'Attendance Date' = ThisRecord.'Attendance Date'
)
),
LookUp(
Attendance_Tracker,
'Mail_Id' = ThisRecord.'Mail_Id' && 'Attendance Date' = ThisRecord.'Attendance Date'
);
{
'Full_Name': ThisRecord.'Full_Name',
'Mail_Id': Lower(ThisRecord.'Mail_Id'),
'Attendance_Status': attendanceStatusDropdown.Selected.'Attendance_Status',
'Attendance Date': Text(
attendanceDatePicker.SelectedDate,
"mmm-dd-yyyy"
)
},
{
'Full_Name': ThisRecord.'Full_Name',
'Mail_Id': Lower(ThisRecord.'Mail_Id'),
'Attendance_Status': attendanceStatusDropdown.Selected.'Attendance_Status',
'Attendance Date': Text(
attendanceDatePicker.SelectedDate,
"mmm-dd-yyyy"
)
}
)
)
);
Set(
varTimeDiff,
DateDiff(
varTimeStart,
Now(),
TimeUnit.Seconds
)
);
Clear(colSelectedData);
Notify(
"Attendance Details were updated successfully in : " & varTimeDiff & " seconds",
NotificationType.Success
)
But this creates a new record every time leading to duplicate records for the same date. What I want to achieve is to
1. Update the existing record if for a user the Attendance status has already been populated for the selected Date!
2. Create a new record if Attendance hasn't been marked for the selected Date.
Please provide your valuable insights on this use case.