I have a dropdown that populates a collection which is then represented in a gallery. I have a save button to save the items in the gallery to my Attendance table. Please see attached screenshot1 of the canvas app screen and I also attached an ERD.
The problem I am having is, when I click Save, it saves the first student ID that exists in my Students table instead of the corresponding StudentID from that gallery item (see attached screenshot 2 of the Attendance results after clicking Save).
Here is the code for the OnChange in the dropdown:
Set(SelectedClass, DropdownClass.Selected);
ClearCollect(
FilteredEnrollments,
AddColumns(
Filter(
ShowColumns(
Enrollments,
EnrollmentID, ClassIDe, StudentIDe
),
crff0_ClassID.ClassIDc = SelectedClass.ClassIDc
),
StudentName,
crff0_StudentID.StudentFirstName & " " & crff0_StudentID.StudentLastName,
StudentID,
crff0_StudentID.StudentIDs,
StudentRecord,
crff0_StudentID
)
)
Here is the code for the Save button:
ForAll(
AttendanceGallery.AllItems,
Patch(
Attendance,
Defaults(Attendance),
{
Date: Today(),
ClassIDa: SelectedClass,
StudentIDa: ThisRecord.StudentRecord,
AttendanceCode: AttendanceCodeInput.Text,
AttendanceNote: AttendanceNoteInput.Text
}
)
)