cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

PowerApps Help - Patch Statement Filter for User

Hello Everyone,

 

I have an application which stores check in and check out data of employees and using SP List i.e Attendance.

 

When Someone Checks in, the Patch statement enters data, with current date and Status as "IN", and then other employee enters it's check in data and so on.

 

The issue is when I go for check out at the day end, I can't check out as my entry is above the one which has already Checked out.

My Entry is 2nd Last 

Sp.png

 

Check in Button Code:

  Patch(
       Attendance,    /*my SP List*/
        Defaults(Attendance),
        {
          Title: "Check In&Out Test",
          User: MyUser,
          'User Email': User().Email,
           WorkDate:Today(),
          Check_x0020_In: Now(),
          Status: "IN"
        }
    ); 
Navigate(CheckInSuccess,ScreenTransition.Cover)


Check Out Button Code:

Refresh(Attendance);
If(
    First(Sort(Attendance,Modified,Descending)).Status="IN",
    Patch(
      Attendance,
       First(Sort(Attendance,Modified,Descending)),
       {
         Check_x0020_Out: Now(),
         Status: "OUT"
       }
     )
);
Navigate(CheckOutSuccess,ScreenTransition.Cover)


In Check out button, I am using First and Descending and status = "IN", but in SP List the last record is already checked out and Status Out, though which I am not able to check on my entry.

 

How can I Filter this Code for every User? on each day.

 

Help.
@

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Try this code.

 

 

Refresh(Attendance);
If(
 CountRows(Filter( ENTER YOU FILTER CONDITIONS )) > 0, 
 Patch(
      Attendance,
       First( Filter(Attendance,ENTER YOU FILTER CONDITIONS)),
       {
         Check_x0020_Out: Now(),
         Status: "OUT"
       }
     )
   
  
);
Navigate(CheckOutSuccess,ScreenTransition.Cover)

 

 

You need to define filter conditions, You can filter the record by username the check in status or today date.  Example

 

'User Email' = test@test.com,'Status'="IN"

 

 

 

Please click Accept as Solution if it resolved your problem or give it a Thumbs Up if it helped you in anyway this will allow other people to search correct solutions effectively.

Thanks,

Rahber

View solution in original post

2 REPLIES 2
Super User
Super User

Try this code.

 

 

Refresh(Attendance);
If(
 CountRows(Filter( ENTER YOU FILTER CONDITIONS )) > 0, 
 Patch(
      Attendance,
       First( Filter(Attendance,ENTER YOU FILTER CONDITIONS)),
       {
         Check_x0020_Out: Now(),
         Status: "OUT"
       }
     )
   
  
);
Navigate(CheckOutSuccess,ScreenTransition.Cover)

 

 

You need to define filter conditions, You can filter the record by username the check in status or today date.  Example

 

'User Email' = test@test.com,'Status'="IN"

 

 

 

Please click Accept as Solution if it resolved your problem or give it a Thumbs Up if it helped you in anyway this will allow other people to search correct solutions effectively.

Thanks,

Rahber

View solution in original post

Hi @Rahber ,

 

It Worked Thanks, I applied the User and Today Filter and the app is now working fine Thanks!!

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,882)