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)}
)
);