cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cmurfree
Frequent Visitor

Write to Sharepoint List from input in Gallery

I am trying to build, what I thought was a simple attendance app.  I have one datasource that populates a gallery with the names of the students in a particular class.  The priority with the app is ease of use (leading to better compliance) for the teachers. Therefore, I wanted to add a dropdown box ("Here", "Not Here", "Excused", "Late") right into the gallery, like so:

cmurfree_1-1624985919542.png

 

Again, for efficiency, I have defaulted to the most likely choice "Here" within the dropdown box.  

 

My problem is once the teacher takes attendance for each individual (hopefully only having to toggle a few dropdown selections to other choices) I do not know how to write that data to a blank sharepoint list that will collect the attendance for the chosen date.

 

I thought maybe I could use Patch, but I don't know how to use that if the teacher never actually touches a certain student's dropdown box because the default (Here) is true. So something like OnClick or OnCheck wouldn't work. 

 

I also thought maybe I could use SubmitForm or something like that to have a button that submitted everyone's at once, but I don't know if that is possible. 

 

Suggestions? 

1 ACCEPTED SOLUTION

Accepted Solutions

OK, the basic functionality you can put in the OnSelect of a submission button is something like:

ForAll(myGallery.AllItems,
    Patch(mySPList,
        Defaults(mySPList),
        {
             Name: Concatenate(ThisItem.FirstName," ",ThisItem.LastName),
             Date: myDatePicker.SelectedDate,
             StudentID: ThisItem.StudentID,
             Group: ThisItem.Group,
             Attendance: ThisItem.myAttendanceDD.Selected
        }
    )
)

            

 

Note: the names of controls/lists above starting with "my" need to be edited to the names of the ones in your app. This is free typed, so possible errors in there. This code will make separate lines in your SP list for each student's attendance selection on that day.

 

Try it and let us know if this helps you out.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
BCLS776
Super User
Super User

Your best solution depends a bit on your data source structure. Are you able to share what columns form your records? Two main options are some sort of form submission, or a ForAll/Patch combination.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
cmurfree
Frequent Visitor

Thanks! I'm not sure if this is what you mean (real newb here) but the columns I am trying to write to in the Sharepoint List are: Name, Student ID, Date, Group, and Attendance(Here, Not Here, Excused, or Late).  

 

The datasource I am pulling from has FirstName, LastName, Student ID, and Group as it's columns. 

OK, the basic functionality you can put in the OnSelect of a submission button is something like:

ForAll(myGallery.AllItems,
    Patch(mySPList,
        Defaults(mySPList),
        {
             Name: Concatenate(ThisItem.FirstName," ",ThisItem.LastName),
             Date: myDatePicker.SelectedDate,
             StudentID: ThisItem.StudentID,
             Group: ThisItem.Group,
             Attendance: ThisItem.myAttendanceDD.Selected
        }
    )
)

            

 

Note: the names of controls/lists above starting with "my" need to be edited to the names of the ones in your app. This is free typed, so possible errors in there. This code will make separate lines in your SP list for each student's attendance selection on that day.

 

Try it and let us know if this helps you out.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

cmurfree
Frequent Visitor

You are briliant! Thank you very much! That worked!  The only problem I am having now is: the use can press the save all button as much as they want duplicate records will be created.  

 

I want to preserve the ability to press the button multiple times (in case someone has to go in and change something or fix a mistake) but I want to try and find a way to check if a record already exists before it creates a new one.  

 

I tried to write an If statements using IsEmpty after filtering by the StudentID and Date, but it doesn't seem to work. Can you use If within ForAll? Any last thoughts? You've already been hugely helpful!

 

Thanks everyone!

You are right, each time that button is pressed, a full set of records are created - it's the blunt way to add a lot of records at once.

 

Your next question gets much broader, so I'll offer a few pointers that can help with your app structure and some searches on here:

  1. Consider different screens for a bulk attendance list and editing specific records
  2. The Sharepoint forms integration capabilities are really helpful in handling a lot of the background work and error checking. Try doing some searches on this forum and here related to the SubmitForm, EditForm, NewForm functions

Once you get some really specific questions back you can't find in the forums, do post again.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,746)