cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ahmadfurqan
New Member

QR Code Scan for Check in & Check Out

Hi, I'm building a personnel on board tracking system.

 

the ideas is so simple. every time you scan the qr code, it will be patched into the datasource.

 

the question is, how to make patch formula so if a employee who last scan "CHECKED IN", then the next patch input automatically be "CHECKED OUT". 

 

and if the employee scan the QR code again, it will be patched as "CHECKED IN" again. 

 

i tried this formula but it doesn't work.

OnScan=

 

Patch(Table1,{CICO:If(IsMatch(Last(Filter(Table1,Name=BarcodeScanner1.Value).CICO).CICO,"IN"),"OUT",
IsMatch(Last(Filter(Table1,Name=BarcodeScanner1.Value).CICO).CICO,"OUT"), "IN")
,
Name:BarcodeScanner1.Value,
Date:Text(Now(),"dd/mm/yyyy"),
Time: Now() })

 

 

thanks

3 REPLIES 3
Ramole
Super User
Super User

@ahmadfurqan 
I have moved your post to correct section so you will get quicker response for help, going forward if you need any help post it this section please 
https://powerusers.microsoft.com/t5/Power-Apps-Community/ct-p/PowerApps1  

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.
WarrenBelz
Super User
Super User

Hi @ahmadfurqan ,

Firstly, note that Date and Time are very bad names for fields, but I have included them in the below for structure

With(
   {
      wScan:
      LookUp(
         Sort(
            Table1,
            ID,
            Descending
         ),
         Name = Self.Value
      )
   },
   If(
      wScan.CICO = "IN" && IsToday(DateValue(wScan.Date))
      Patch(
         Table1,
         {ID: wScan.ID},
         {
            CICO: "OUT",
            Date: Text(Now(),"dd/mm/yyyy"),
            Time: Now() 
         }
      ),
      Patch(
         Table1,
         Defaults(Table1),
         {
            CICO: "OUT",
            Date: Text(Now(),"dd/mm/yyyy"),
            Time: Now() 
         }
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

WarrenBelz
Super User
Super User

Hi @ahmadfurqan ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (1,631)