web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adjust LookUp on QR Sc...
Power Apps
Answered

Adjust LookUp on QR Scan and Patch

(0) ShareShare
ReportReport
Posted on by 25

Hi there!

 

I'm still new to PowerApps and working on a QR scanner to use as a time clock for our team. Thanks to the help of the wonderful people on this forum we have got this working 😀

 

At present we issue a QR code to everyone which splits into Name;WorkArea;ID on scan and using one button in PowerApps to "Clock In" and "Clock Out" everyone. 

 

One issue I would like to learn how to work around is what happens if someone clocks in or out multiple times in a day e.g. they have scanned in to start the day then scanned out and then have had to come back to work. At present when someone "Clocks In" they create a new Sharepoint record - when they "Clock Out" the LookUp works brilliantly and records the time in "Clock Out Time Stamp".  However if they scan the QR Code again after a time already exists in the "Clock Out Time Stamp" on the same day it will just flat out overwrite today's record with an updated time and I need it to create a whole new entry in Sharepoint.  

 

I've tried a few things but I'm lost as to how to get this to happen around everything else...if anyone could point me in the right direction that would be extremely helpful!

 

Screenshots of columns in Sharepoint with examples - OnScan of the BarcodeReader current formula below. Any help would be massively appreciated and thanks in advance to anyone who takes a look!

 

With(
{
_Title:
Last(FirstN(
Split(
First(BarcodeReader1_1.Barcodes).Value,
";"
),1
)).Value,
_Area:
Last(FirstN(
Split(
First(BarcodeReader1_1.Barcodes).Value,
";"
),2
)).Value,
_HoddyID:
Last(FirstN(
Split(
First(BarcodeReader1_1.Barcodes).Value,
";"
),3
)).Value
},
With(
{
_Exist:
LookUp(
'Ahoy Staff 2024',
Title = _Title && 'Work Area' = _Area && HoddyID = _HoddyID && DateOnly = Today()
)
},
If(
!IsBlank(_Exist.ID),
Patch(
'Ahoy Staff 2024',
{ID: _Exist.ID},
{'Clock Out Time Stamp': Now()}
),
Patch(
'Ahoy Staff 2024',
Defaults('Ahoy Staff 2024'),
{
Title: _Title,
'Work Area': _Area,
HoddyID: _HoddyID,
DateOnly: Today(),
'Clock In Time Stamp': Now()
}
)
)
)
);
Navigate(Successimo);
Set(
startTimer2,
true
)

 

Thanks 

 

Clock In And Out Scan 1 and 2.JPG
Clock In And Out Scan 3.JPG
Categories:
I have the same question (0)
  • elseb Profile Picture
    774 Moderator on at

    Hi,

     

    You could check if user the record doesn't exist or if both date columns are populated on the last created record for the user operating the app, and if that comes back true create new record, else update the record with clock out date.

     

    Seb

  • scottf1 Profile Picture
    25 on at

    Hi @elseb,

     

    Thanks for that - just looking for some suggestions on how I actually write that formula?

     

    Thanks!

  • elseb Profile Picture
    774 Moderator on at

    Patch button:

    If(
     IsBlank(
     LookUp(
     colClockins,
     employee_id = Value(TextInput3.Text) && IsBlank(date_out)
     )
     ),
     Patch(
     colClockins,
     Defaults(colClockins),
     {
     employee_id: Value(TextInput3.Text),
     date_in: Now(),
     is_clockin: true
     }
     ),
     Patch(
     colClockins,
     LookUp(
     colClockins,
     employee_id = Value(TextInput3.Text) && IsBlank(date_out)
     ),
     {
     date_out: Now(),
     is_clockin: false
     }
     )
    )

    my database:

    ClearCollect(
     colClockins,
     {
     employee_id: 1,
     date_in: DateValue(""),
     date_out: DateValue(""),
     is_clockin: true
     },
     {
     employee_id: 1,
     date_in: DateValue(""),
     date_out: DateValue(""),
     is_clockin: false
     }
    )

    The employee_id is taken from text input called: 

    TextInput3

    You can replace the source of the employee_id or whatever you use to track the person with your data, and adjust the code to your needs but the above is tested and works.

    Hope this helps

  • scottf1 Profile Picture
    25 on at

    Hi @elseb ,

    I've spent a few days trying to get this and can't get this to work unfortunately. 

    Part of this issue seems to be that the Patch button is also the same button I have splitting the QR code before we start patching and LookUp and it just starts putting blank entries into Sharepoint. 

    Any other thoughts?

    Thanks! 

  • elseb Profile Picture
    774 Moderator on at

    have you used the code I wrote for you to test the functionality? Just copy and paste what I gave you into fresh screen and see how it works. 

    The important thing with any even remotely complex tasks is to break it down and make small adjustments, If you not entirely sure what my code does test it first and analyse then replace section by section with your data.

  • Verified answer
    scottf1 Profile Picture
    25 on at

    Hi @elseb 

     

    I certainly tried using your whole code with no success - however, what I did find from your code is exactly what I needed ( a modified version on mine of &&IsBlank('Clock Out Time Stamp') and your suggestion of making small adjustments. Everything is working how I wanted it. Thank you so much for the help - I really appreciate it!!!!!!! Code below - 

    With(
    {
    _Title:
    Last(FirstN(
    Split(
    First(BarcodeReader1_1.Barcodes).Value,
    ";"
    ),1
    )).Value,
    _Area:
    Last(FirstN(
    Split(
    First(BarcodeReader1_1.Barcodes).Value,
    ";"
    ),2
    )).Value,
    _HoddyID:
    Last(FirstN(
    Split(
    First(BarcodeReader1_1.Barcodes).Value,
    ";"
    ),3
    )).Value
    },
    With(
    {
    _Exist:
    LookUp(
    'Ahoy Staff 2024',
    Title = _Title && 'Work Area' = _Area && HoddyID = _HoddyID && DateOnly = Today() && IsBlank('Clock Out Time Stamp')
    )
    },
    If(
    !IsBlank(_Exist.ID),
    Patch(
    'Ahoy Staff 2024',
    {ID: _Exist.ID},
    {'Clock Out Time Stamp': Now()}
    ),

    Patch(
    'Ahoy Staff 2024',
    Defaults('Ahoy Staff 2024'),
    {
    Title: _Title,
    'Work Area': _Area,
    HoddyID: _HoddyID,
    DateOnly: Today(),
    'Clock In Time Stamp': Now()
    }

    ))

    )
    )
    ;
    Navigate(Successimo);
    Set(
    startTimer2,
    true
    )

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 413

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
timl Profile Picture

timl 315 Super User 2026 Season 1

Last 30 days Overall leaderboard