Hi community!
I am building a POC for a timeclock system using an NFC tablet and Power Apps. The tablets are permanently mounted at entry and exit points in several locations. Staff use an NFC device, either a card or a digital wallet on their phone, to clock on and off by tapping their device against the tablet.
My app has a button called btnScanCard with the following code on the OnSelect property:
With(
{nfcInput: ReadNFC()},
IfError(
nfcInput,
If(
FirstError.Message = "Tag not found",
// No tag detected
If(
ckbAutoScan.Checked,
// TODO: re-run the OnSelect of this control
true
),
// Error with detected tag
Error(
{
Kind: ErrorKind.NotFound,
Message: "We couldn't read your tag. Please try again."
}
)
)
);
/*
Lookup user and do stuff
*/
If(
!IsBlank(nfcInput),
Navigate('Welcome User')
)
)
I am running into issues with the ReadNFC() function not staying active for more than a minute or so. At which point, the button must be selected again. I need the NFC reader to be active until a device is scanned.
I've been trying to circumvent the self-referential rule by selecting controls which select this control, but Power Apps seems to be aware of all the indirect references. I've also tried using a checkbox, e.g., uncheck and check it and have the Select statement run on check; however, that approach didn't work.
I was able to navigate away from the screen and back to it and then run the Select() but that seems overkill. It's a simple while loop. Should I use a timer for this?
Would love to hear some approaches to this.
Thanks
I solved this by moving the code to a timer control and implementing a while loop similar to what is outlined here
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional