I have a power app which people use to scan in and scan out of the building, they use a tag or manual input (mostly a tag with NFC) to check in or check out.
The data is saved in a simple dataverse table with the following columns:
Scancode / StartDate / StartTime / EndDate / EndTime
They scan a code from an NFC tag, which is entered in a text input control in my app. On the OnChange, it checks the following things (see code below):
- if it is a valid tag (code)
- If they haven't clocked in the past 30 seconds.
- Depending on whether they checked in or out the last time, it moves to a different success screen.
- If they checked out they move to a checkout screen;
- If they checked in they moved to a checking screen.
- In addition, it calculates the hours between start end now()
However, in our testing fase, people are experiencing that they need to scan twice. First time, they move to the succes screen, but it isnt patched to the database. Second time it works.
The issue doesn't happen with everybody and i cannot see a pattern.
Can somebody help me with this issue?
Below my code.
Set(varScanCode, Trim(Self.Text));
UpdateContext({ ScanCode: varScanCode, varSpinner: true });
If(
IsBlank(LookUp(ExtraEmployees, 'Tag Nummer' = varScanCode)),
UpdateContext({ varLabel: "Invalid code, please scan again!" }),
Set(varLastPatch, Blank());
Set(varMedewerkerPersnr, LookUp(ExtraEmployees, 'Tag Nummer' = varScanCode).Persnr);
With(
{
OpenRecord: LookUp(KloksysteemLogs, code = varScanCode && IsBlank(EindTijd)),
LastUpdate: First(SortByColumns(Filter(KloksysteemLogs, code = varScanCode),"modifiedon",SortOrder.Descending)).'Modified On'
},
If(
!IsBlank(LastUpdate) && DateDiff(LastUpdate, Now(), TimeUnit.Minutes) < 0.5,
UpdateContext({varLabel:"You can only clock in or clock out again 30 seconds after your last action."}),
If(
!IsBlank(OpenRecord),
// Clock out
Set(
varLastPatch,
Patch(
KloksysteemLogs,
OpenRecord,
{
code: varScanCode,
EndDate: DateValue(Now()),
EndTime: Now(),
Uren: Round(DateDiff(OpenRecord.StartTime, Now(), TimeUnit.Minutes)/60, 2)
}
)
);
Navigate(SuccesScreenOut, ScreenTransition.Fade),
// Clock in
Set(
varLastPatch,
Patch(
KloksysteemLogs,
Defaults(KloksysteemLogs),
{
code: varScanCode,
StartDate: DateValue(Now()),
StartTime: Now(),
EndDate: Blank(),
EndTime: Blank()
}
)
);
Navigate(SuccesScreenIn, ScreenTransition.Fade)
)
)
)
)


Report
All responses (
Answers (