Reference > Script steps reference > Control script steps > Configure NFC Reading
 

Configure NFC Reading

Scans or stops scanning for NFC (near field communication) tags.

See also 

Options 

Action specifies whether to start (Read) or stop (Cancel) scanning for NFC tags.

The following options are used only for Read:

Script specifies the script to be run when a tag is read, when an error occurs, if the user cancels the operation, or if the operation is canceled by another Configure NFC script step using the Cancel option.

Parameter (optional) specifies a script parameter for the script.

Timeout (optional) automatically cancels the Read operation after the specified number of seconds.

Continuous Reading (optional) if the value is non-zero, sets the script step to read tags until the user taps the Cancel button or until the timeout parameter is met. If this option is not specified, only one tag is read.

Compatibility 

 

Product 

Supported 

FileMaker Pro 

No 

FileMaker Go 

Yes 

FileMaker WebDirect 

No 

FileMaker Server 

No 

FileMaker Cloud products 

No 

FileMaker Data API 

No 

Custom Web Publishing 

No 

Originated in version 

19.0

Description 

Use this script step to scan or stop scanning for NFC tags, which are programmed with a small amount of data. Data in NFC tags is often a URL that uses protocols such as http, tel, fmp, and mailto.

The Get(ScriptParameter) function must be called in the script specified in the Script option to return the NFC tag’s multiline parameter.

The following table describes each line of the parameter. For more information on NFC parameters, see the NDEF specification:

 

Line number

Parameter description

1

The reason the script was called. Returns:

TagRead if an NFC tag was read

CanceledByUser if the user tapped the Cancel button

CanceledByError if an error occurred

2

Error string

3

Optional script parameter specified in the Specify Script dialog box

4

Number of multiline parameter records that were read from the tag

5

Identifier of the multiline parameter

6

String value of the multiline parameter

7

Type of the multiline parameter

8

Type Name Format of the multiline parameter

Lines 5 through 8 are repeated for each multiline parameter record that read from the tag (the value of line 4).

Notes 

Only one read operation may be in progress at the same time. If a read operation is in progress when a cancel operation is performed, the read operation is canceled.

If the Open URL script step is used after an NFC tag is scanned, it opens the URL with the appropriate application. For example, an fmp URL opens a specified FileMaker Go file and runs a script if specified, a web page URL opens in a browser, a mailto URL opens in the Mail app, and a tel URL opens the Phone app.

Example 1 

Initiates reading of a single NFC tag and stops after reaching the timeout value specified in the NFC::Timeout field. After the tag is read, the multiline parameter data in the tag is set in the fields specified in the Parse Result sub-script, which is called from the Scan One Finished sub-script.

Main script: Scan One

Go to Layout [ "NFC Tag" ; Animation: None ]
Configure NFC Reading [ Action: Read ; Script: "Scan One Finished" ; Parameter: "The current date and time is " & Get ( CurrentTimestamp ) ; Timeout: NFC::Timeout ]

Sub-script 1: Scan One Finished

Set Variable [ $scriptParam ; Value: Get ( ScriptParameter ) ]
Perform Script [ Specified: From list ; "Parse Result" ; Parameter: $scriptParam ]
Show Custom Dialog: [ "NFC Scan Finished" ; $scriptParam ]

Sub-script 2: Parse Result

New Record/Request
Set Field [ NFC::Text ; Get ( ScriptParameter ) ]
Set Field [ NFC::Tag ; GetValue ( NFC::Text ; 6 ) ]
Set Field [ NFC::PayloadCount ; GetValue ( NFC::Text ; 4 ) ]
Set Field [ NFC::Result ; GetValue ( NFC::Text ; 1) & GetValue ( NFC::Text ; 2 ) ]
Set Field [ NFC::ReadTimestamp ; Get ( CurrentTimestamp ) ]
Set Field [ NFC::ID ; GetValue ( NFC::Text ; 5) ]
Set Field [ NFC::Type ; GetValue ( NFC::Text ; 7) ]
Commit Records/Requests [ With dialog: Off ]

Example 2 

Initiates reading of multiple tags and stops after reaching the timeout value specified in the NFC::Timeout field or if scanning is canceled. As the tags are read, the multiline parameter data in the tag is set in the fields specified in the Parse Result sub-script (see example 1).

Main script: Scan Multiple

Configure NFC Reading [ Action: Read ; Script: "Parse Result" ; Parameter: "Scanning started at " & Get ( CurrentTimestamp ) ; Timeout: NFC::Timeout ; Continuous Reading: 1 ]
Go to Layout [ "NFC Scan List"; Animation: None ]

Example 3 

Initiates tag reading and attempts to open a URL if one exists in line number 6 of the multiline parameter. Scanning stops after reaching the timeout value specified in the NFC::Timeout field or if scanning is canceled. After the tag is read, the multiline parameter data in the tag is set in the fields specified in the Parse Result sub-script (see example 1), which is called from the Open from Scan sub-script.

Main script: Scan and Open

Configure NFC Reading [ Action: Read ; Script: "Open from Scan" ; Parameter: "Scanning started at " & Get ( CurrentTimestamp ) ; Timeout: NFC::Timeout ]
Go to Layout [ "NFC Scan List"; Animation: None ]

Sub-script: Open from Scan

Set Variable [ $scriptParam ; Value: Get ( ScriptParameter ) ]
Perform Script [ Specified: From list ; "Parse Result" ; Parameter: $scriptParam ]
Commit Records/Requests [ With dialog: Off ]
If [ NFC::PayloadCount > 1 ]
Open URL [ With dialog: On ; NFC::Tag ]
End If

Related topics 

Script steps reference (alphabetical list)

Script steps reference (category list)