Create a Record Entry Alternative to Using a QR Code Scan
This is a way to scan an NFC to create the record entry without allowing a form to be filled out/edited (all behind the scenes). This will require an app to write to NFC (Example: NFC Tools for Android), and then the rest is done via basic JavaScript.
Under construction
Step 1
In this walkthrough, I want the form to have three fields.
- Submitted By:
- Location (connection field)
- Date and Time
The submitted By will be a record rule of whoever is logged in. Date and time will also be a record rule to the current date and time. The Location will be the ID of the connection field.
Step 2
Get the location's ID and save that value as a basic text value to the NFC chip.
Make sure you write it to the card as a text value.
In my case, I have two chips (or 2 locations); one has the value of “4MXQJdrZ6v” and the other “DVWQWRNZ49.”
Step 3
Create a form on a page without any fields but with three rules. This is all we need to do on the form part:
The key is setting the Location value to the Browser Local Storage value of ‘locationId.’
Step 4
Find the Id of your component by hovering over the info icon.
Step 5
Add the following code to the JavaScript tab of your page.
TB.render('component_X', function(data) {
const ndef = new NDEFReader();
async function startScanning() {
await ndef.scan();
ndef.addEventListener("reading", ({
message,
serialNumber
}) => {
const textDecoder = new TextDecoder(message.records[0].encoding);
var cardValue = textDecoder.decode(message.records[0].data);
localStorage.setItem('locationId', cardValue);
data.ele.find('.form-submit .af-form-submit').click();
});
}
startScanning();
});
Step 6
You may additionally add a class to the form submit button of ‘hide’ so we don’t ever see it.
Original Community Post:
QR Code Scan Creates Record Entry - Community Discussions / How Do I - Tadabase Community
We'd love to hear your feedback.