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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / how to read NFC in mul...
Power Apps
Answered

how to read NFC in multiple data base.

(0) ShareShare
ReportReport
Posted on by 39
 
Hi, 
 
I am currently facing an issue where the NFC popup and read functionality does not work.
This problem occurs only after I introduce multiple data sources.
Below is the code I am using to read NFC.  
 
I would greatly appreciate any insights or solutions you might have to resolve this issue.
Thank you in advance for your help.
 
// Set ScanSuccess to true to indicate the scan is in progress
Set(
    ScanSuccess,
    true
);
// Read NFC tag and store the result in varNFCTag
Set(
    varNFCTag,
    ReadNFC()
);
// Clear and populate Equipmentrecords collection based on NFC tag identifier (from DMAT)
ClearCollect(
    Equipmentrecords,
    Filter(
        DMAT,
        NFCTag = Text(varNFCTag.Identifier)
    )
);
// Clear and populate ConsumableRecords collection based on NFC tag identifier (from CONSUMABLE MATERIALS)
ClearCollect(
    ConsumableRecords,
    Filter(
        'CONSUMABLE MATERIALS',
        NFCTag = Text(varNFCTag.Identifier)
    )
);
// Clear and populate StockRecords collection based on NFC tag identifier (from Stock Items)
ClearCollect(
    StockRecords,
    Filter(
        'Stock Item',
        NFCTag = Text(varNFCTag.Identifier)
    )
);
// Clear and populate Borrowrecords collection based on NFC tag identifier (from DMATLog)
ClearCollect(
    Borrowrecords,
    Filter(
        DMATLog,
        NFCTag = Text(varNFCTag.Identifier)
    )
);
// Check if NFC tag read is successful
If(
    !IsBlank(varNFCTag.Identifier),
    // Patch details to DMATLog for Equipmentrecords if not empty
    If(
        !IsEmpty(Equipmentrecords),
        Patch(
            DMATLog,
            Defaults(DMATLog),
            {
                NFCTag: Text(varNFCTag.Identifier),
                ScanTime: Now(),
                ScannerLocation: Text(Location.Latitude) & "," & Text(Location.Longitude),
                UserID: User().Email,
                Approver: First(Equipmentrecords).MWC.DisplayName,
                Title: First(Equipmentrecords).'Item Description',
                // Ensure correct field name
Status: "UPDATE LOCATION",
                TrackID: Concatenate(
                    User().FullName,
                    "-",
                    Text(varNFCTag.Identifier),
                    "-",
                    Text(First(DMATLog).ID)
                ),
                Remarks: "Last Location Found"
            }
        )
    );
    // Patch details to DMATLog for ConsumableRecords if not empty
If(
        !IsEmpty(ConsumableRecords),
        Patch(
            DMATLog,
            Defaults(DMATLog),
            {
                NFCTag: Text(varNFCTag.Identifier),
                ScanTime: Now(),
                ScannerLocation: Text(Location.Latitude) & "," & Text(Location.Longitude),
                UserID: User().Email,
                Approver: First(ConsumableRecords).Supervisor.DisplayName,
                Title: First(ConsumableRecords).Title,
                Status: "UPDATE LOCATION",
                TrackID: Concatenate(
                    User().FullName,
                    "-",
                    Text(varNFCTag.Identifier),
                    "-",
                    Text(First(DMATLog).ID)
                ),
                Remarks: "Last Location Found"
            }
        )
    );
    // Patch details to DMATLog for StockRecords if not empty
If(
        !IsEmpty(StockRecords),
        Patch(
            DMATLog,
            Defaults(DMATLog),
            {
                NFCTag: Text(varNFCTag.Identifier),
                ScanTime: Now(),
                ScannerLocation: Text(Location.Latitude) & "," & Text(Location.Longitude),
                UserID: User().Email,
                Approver: First(StockRecords).Supervisor.DisplayName,
                Title: First(StockRecords).Title,
                Status: "UPDATE LOCATION",
                TrackID: Concatenate(
                    User().FullName,
                    "-",
                    Text(varNFCTag.Identifier),
                    "-",
                    Text(First(DMATLog).ID)
                ),
                Remarks: "Last Location Found"
            }
        )
    )
);
// Notify the user if NFC tag read failed or no matching record found in DMAT
If(
    IsBlank(varNFCTag.Identifier) || (IsEmpty(Equipmentrecords) && IsEmpty(ConsumableRecords) && IsEmpty(StockRecords)),
    Notify(
        "NFC tag read failed or no matching item found. Please ensure your device supports NFC reading and that a tag is present and registered.",
        NotificationType.Error
    )
);
// Notify the user if item was successfully read and navigate
If(
    !IsBlank(varNFCTag.Identifier) && !IsEmpty(Equipmentrecords),
    Notify(
        "NFC tag read successful!",
        NotificationType.Success
    );
    Navigate(
        EquipPage,
        ScreenTransition.None,
        {NFCTag: Text(varNFCTag.Identifier)}
    )
);
Categories:
I have the same question (0)
  • Nandit Profile Picture
    1,568 Moderator on at
     
    I think ideally you should post some context regarding what you are trying to achieve with this. Its a long code and it would be really helpful. 
     
    Kind regards,
    Nandit
  • Nandit Profile Picture
    1,568 Moderator on at
    Ah, looks like you posted some context but it goes away as soon as the page loads. This has been happening lately on the forum.
     
    I managed to grab a screenshot:
  • Verified answer
    Nandit Profile Picture
    1,568 Moderator on at
     
    Nothing looks wrong in your code when I look at it. Did you try to analyse which part is failing or from which step the code stops working? I'd suggest running your code in parts and checking that. Also, I'd suggest passing "false" in your Patch statements as the second argument as that's missing. Like this:
     If(
            !IsEmpty(Equipmentrecords),
            Patch(
                DMATLog,
                Defaults(DMATLog),
                {
                    NFCTag: Text(varNFCTag.Identifier),
                    ScanTime: Now(),
                    ScannerLocation: Text(Location.Latitude) & "," & Text(Location.Longitude),
                    UserID: User().Email,
                    Approver: First(Equipmentrecords).MWC.DisplayName,
                    Title: First(Equipmentrecords).'Item Description',
                    // Ensure correct field name
    Status: "UPDATE LOCATION",
                    TrackID: Concatenate(
                        User().FullName,
                        "-",
                        Text(varNFCTag.Identifier),
                        "-",
                        Text(First(DMATLog).ID)
                    ),
                    Remarks: "Last Location Found"
                }
            ), false
        );
    Hope this helps. Do share your findings.
     
    Kind regards,
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard