Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

ReadNFC function until scanned

(0) ShareShare
ReportReport
Posted on by 186

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

  • Verified answer
    lukas.schauffele Profile Picture
    186 on at
    Re: ReadNFC function until scanned

    I solved this by moving the code to a timer control and implementing a while loop similar to what is outlined here

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard