web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Save button to save al...
Power Apps
Unanswered

Save button to save all gallery items

(1) ShareShare
ReportReport
Posted on by 36

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
 }
 )
)

 

 

Screenshot 2 - Attendance Results.png
Screenshot 1 - Canvas App Screen.png
ERD.png
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,963 Moderator on at

    Hi @WhatDidDavidDo 


    Can you please verify what is bound in the Gallery Control. I know you see the correct information there, and it seems like your ForAll is just fine, so I am guessing you may have bound a different column and are now using the wrong one.

     

    Also

    It would be faster to use the Collection you already have that is bound to the gallery than iterating the gallery. (its personal choice comparisons)


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • WhatDidDavidDo Profile Picture
    36 on at

    Please forgive me as I am in the very early stages of learning PowerApps.

    The Items property of my AttendanceGallery is FilteredEnrollments. Is that what you mean by what is bound to the gallery control?

     

    And I'm trying to understand what you mean by iterating over the gallery. Are you saying I could potentially set the collection to display everything I want (including each Attendance Code and Attendance Note instance) rather than what I'm doing now which is pulling just the student/class information into the collection and then adding TextInputs to pull the extra Attendance Code/Note information?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 883

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 477

Last 30 days Overall leaderboard