cancel
Showing results for 
Search instead for 
Did you mean: 

Apps with Batch Saving & Single Record Updating [Part 3: Final]

Continue from Part 2…

 

In the previous Chapter, I had shared on the basic coding for SAVE New data.

In this Final Chapter, let's concentrate on how can we UPDATE a single record using

- UpdateIf function based on CONDITION

 

Why use Toggle?

As I was responding to @OlaH’s question, and understand that using Toggle looks more gorgeous and App’s like looking, I also found that Toggle is very suitable for small screen, user-friendly and widely used in most of the Apps.

 

Anyhow, as Toggle hasmany behavior action, this shall be selected carefully:

- OnCheck

- OnUnCheck

- OnChnage

- OnSelect

 

The main reason that I use OnSelect is because I wish to have the UpdateIf being triggered only when selected, NOT OnCheck or OnUnCheck.

[OnChange must be avoided here because when I change the Date, the defaults values will make the Toggle value change to either true / false (defaults value), and this will trigger UpdateIf, In which this is supposed not to happen.]

 

Formula

 

Toggle1.OnSelect =

 

UpdateContext({LoadingIcon: true});

UpdateIf(TableAttendance,

Date = 'Today-Date'.Text && Grade = DropdownGrade.Selected.Result && StudentName = 'Student-Name'.Text && Attendance <> Text(Toggle1.Value),

{Attendance: Toggle1.Value, Reason: DropdownReason.Selected.Value, Teacher: DropdownTeacher.Selected.Result}); UpdateContext({LoadingIcon: false})

 

Select Reason, Change Attendance (Toggle)Select Reason, Change Attendance (Toggle)                    Update in processUpdate in process

Rational Reason

 

What happens when toggle is SELECTED (or changed, and after RELEASE of the toggle button):

  • Since the …. (left to right dots indicating saving in process) is not obvious, again, I use a GIF file to remind of the saving process & turn off after completion of updating
  • -When Date/Grade/StudentName MATCH and Current Selected Attendance (Toggle selected value, either true to false OR false to true) is NOT EQUAL to the actual Attendance Value in Existing datasource, UpdateIf will fire.
  • - {…………} will be used to Update selected field. In this example, Attendance (key reason) is updated, Reason and so does the Teacher (who did the change)
  • For me, the is the most tricky part. Play with it and rest assure you that you will do better than me.
  • -UpdateIf is much faster compare to PATCH or UPDATE because it only save on selected row of records / columns

 

Lastly

 

Patch, ForAll, UpdteIf, with conditions formula, altogether are sufficient in creating a CRUD environment.

[I do not include DELETE in this sample as it is not my intention to delete data]

Appreciate comments for improvement and at the same time, wishing those who needs equivalent application will benefit from this detailed explanation sample.

Feel free to see the:

- Sample Apps

- Sample Data

- Simple demo video

Comments

Thank you so much for adding the attachment sample!

You are most welcome and hope something can be improved further....

Hi there! Thanks for sharing your app! I'm working on something that would provide me with similar functionality to the app you built, but I need to navigate between multiple screens. The trouble i run into is when i navigate from 1 screen to the other and back again, my filtered results gallery disapears. Is there anyway i can get the gallery to stay on the current item selected when i navigate back to my "DailyAttendance" screen? 

 

Daily Attendance ScreenDaily Attendance ScreenProduction Hours ScreenProduction Hours ScreenHit Cancel, back to daily attendance. Gallery is emptyHit Cancel, back to daily attendance. Gallery is emptyClick on drop down, gallery re-populatesClick on drop down, gallery re-populates

Meet Our Blog Authors
  • PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim