cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ChiefPraetor
Level: Powered On

ForAll on Patching a Subgallery

I'm creating a Gradebook for teachers and so far have created a Gallery for the StudentRoster and a Subgallery for the AssignmentsList.  In the rough sketch below, the names on the left are the Gallery, and the 1,2,3, etc. are the Subgallery.

 

image.png

 

I'm trying to Patch data that uses items from both a gallery and a subgallery (though I could easily make it work to just pull from the subgallery if needed).

 

The problem I have is that I can't get it to work the same way as pulling data from a regular Gallery. 
Button Code simply does nothing:

 

ForAll(GradeGallery.AllItems,Patch(tblGradebookMaster,Defaults(tblGradebookMaster),{StudentID:Value(Label30_1.Text),CCRecordID:Label25.Text,Rubric:Value(TextInput2.Text),AsID:Value(Label37.Text)}))

 

 

Currently I'm using a work around 'On Change' to save each one individually automatically:

 

If(IsEmpty(Filter(tblGradebookMaster,StudentID=Value(Label30_1.Text),CCRecordID=Label25.Text,AsID=Value(Label37.Text)))=true,

 

Patch(tblGradebookMaster,Defaults(tblGradebookMaster),{StudentID:Value(Label30_1.Text),CCRecordID:Label25.Text,Rubric:Value(TextInput2.Text),AsID:Value(Label37.Text)}),

 

Patch(tblGradebookMaster,First(Filter(tblGradebookMaster,StudentID=Value(Label30_1.Text),CCRecordID=Label25.Text,AsID=Value(Label37.Text))),{Rubric:Value(TextInput2.Text)}))

 

But it causes issues with the data source when the user updates too quickly and disconnects itself.  This is the only work around I've been able to get though.  I'd much prefer being able to collect the whole table at once, but I'd settle for less.

 

Thank you for your time,

1 ACCEPTED SOLUTION

Accepted Solutions
ChiefPraetor
Level: Powered On

Re: ForAll on Patching a Subgallery

I ended up making a Collection of all the changes through the On Change Property and then Hit a button to 'Save Changes' that patches the Collection to the Record Table.  Works great.

3 REPLIES 3
Community Support Team
Community Support Team

Re: ForAll on Patching a Subgallery

 

Hi @ChiefPraetor,

 

Please take a try to switch the Gallery.AllItems with the actual data source.

For example:

 

ForAll(DataSourceInGallery,
Patch(tblGradebookMaster,
Defaults(tblGradebookMaster),
{StudentID:Value(Label30_1.Text),
CCRecordID:Label25.Text,
Rubric:Value(TextInput2.Text),
AsID:Value(Label37.Text)}))

See if that would make any difference.

 

The workaround seems to be able to update if record exists, and if not, create new.

 

Further, would you please explain a bit for what you would like to achieve here?

We may offer a better solutions with a different control other than the Gallery.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ChiefPraetor
Level: Powered On

Re: ForAll on Patching a Subgallery

I tried your code, but I see the same issue.  Only 7 records are being created.  It isn't reading for every item of the subgallery, just one.

 

The goal is to save every rubric to every student shown.  I've split them into two galleries as there are two variables that must be filtered in a gradebook.   I must be able to change who's in the class (names on the left) and I must be able to change the assignments/number of assignments for the class (Test1, etc. on the top).

 

tblCoreScheduleStudent is a collection of all the students in the course (filtered to create the list in the example for this particular class - CCRecordID)

 

Fields: StudentID, CCRecordID

 

tblGradebookAssignments is a collection of all the Assignments (filtered to create the list in the example for this particular class)

 

Fields: AsID, CCRecordID

 

tblGradebookMaster is a collection of all the rubrics (grades on the given assignments) connected to each student in the class.

 

Fields: StudentID, AsID, Rubric, CCRecordID

 

 

We're trying to patch tblGradebookMaster so that every rubric is patched, whether updated or created new as needed, upon pressing a save button.

 

 

Thank you for your time, I hope some of that made sense =P

ChiefPraetor
Level: Powered On

Re: ForAll on Patching a Subgallery

I ended up making a Collection of all the changes through the On Change Property and then Hit a button to 'Save Changes' that patches the Collection to the Record Table.  Works great.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 172 members 5,103 guests
Please welcome our newest community members: