Build-On Tutorial:

iPad Sign-In

iPad Sign-In: Lesson 3

Filter Registration List by Attendee Name

Lesson Overview

The objective for this lesson is to create functionality to allow a user to filter an event’s registration list by attendee name. You will create a new field, script, and buttons to accomplish this.

Here’s a sneak peek of what you will build:

Step 1 - Create new field for capturing search text

The first step is to create a field for the user to enter search text.

  1. Open the Manage Database dialog (File > Manage > Database…) and activate the Tables tab.
  2. Double-click on the Globals table to see the list of fields it contains.
  3. Add a new field to the Globals table named “g_Registration_Search” of Type: Text.
  1. Double-click on the field name (or select it and click the Options button), to open the Field Options dialog.
    1. Activate the Storage tab.
    2. Check the Use global storage (one value for all records) box.

      Fields with this setting are referred to as global fields. Global fields are helpful for storing or capturing information not specifically belonging to a record. Note that the Event Management Template uses the field name prefix “g_” to indicate global fields.
  1. Close the Manage Database dialog to save the new field.

Step 2 - Add the search field to the registration list layout

  1. Enter Layout mode and navigate to the iPad | Registration List layout.
  2. Select the Header part handle and set its height to 164 pt. This is to make room for the new search field.
  1. Select the Line tool in the status toolbar.
  1. Using the Line tool, draw a horizontal line in the Header part.
    1. The line should span the width of the layout. Set its width to 768 pt, and if necessary, set its height to 0 pt to ensure it is perfectly horizontal.
    2. Set top, left, and right anchors.
    3. Move it slightly under the g_App_Logo field with a left position of 0 pt and a top position of 88 pt.
  1. Duplicate the Name_Last_Initial field and repoint it to the new _GLOBAL::g_Registration_Search field.
  2. Using the Inspector, modify the g_Registration_Search field:
    1. Set the width to 200 pt.
    2. Set top and left anchors.
    3. Set the style to txt Group.Icon.
    4. In the Behavior section of the Data tab, enable Field entry in Browse Mode. Since this is a search field, the user needs to be able to enter it.
  1. Create a button next to the search field. In the Button Setup dialog:
    1. Set it to display an icon only.
    2. Select the magnifying glass icon indicated below.
    3. Set the icon size to 16 pt.
    4. Set the Action: to Single Step. In the subsequent dialog, add the following script step:
Go to Field [ _GLOBAL::g_Registration_Search ]
  1. Further edit the button using the Inspector:
    1. Assign the style btn Icon.Group.
    2. Set the width to 44 pt.
  2. Arrange the search field and button icon so the borders align, as shown below.
  1. Enter Browse mode to save and review your work.

Step 3 - Create a search script

Next you will create a script that searches the event registration list for the search text the user has entered. The user will tap a search button to run this script.

  1. Open the Script Workspace and duplicate the Template Script. Name the new script “iPad: Search Registration ( clear_flag )” and move it into the iOS UI > iPad script folder.

    The script name indicates this script takes a parameter named “clear_flag”. This is an optional parameter that, when specified, indicates the search should be cleared. Amend the “Parameters” comment in the script to indicate this.

    Note: The # and #Assign custom functions are used to pass and parse parameters. The # custom function is generally used to define a script parameter and accepts a key-value pair; the #Assign custom function is called in the script and turns key-value pairs into script variables.

# Parameters:        Specify using # function:     
      $clear_flag (optional) = True, to clear search criteria

  1. Modify the script to parse the parameters and require the starting context to be the Registration table. It should then perform a search based on the search text and optional parameter and sort the results.

    NOTE: See Step 4 for additional detail on the Show Custom Dialog script step.

Allow User Abort [ Off ]
Set Error Capture [ Off ]
Enter Browse Mode [ Pause: Off ]
Freeze Window

# load parameter(s)
Set Variable [ $parameter_parsing_ok; Value: #Assign ( Get ( ScriptParameter ) ) ]
If [ $parameter_parsing_ok = False ]
   # parameters could not be parsed, exit this script and report back
   Exit Script [ Text Result: "error" ]
End If

# required context
If [ Get ( LayoutTableName ) ≠ "REGISTRATION" ]
   Show Custom Dialog [ “Alert" ; "This script can only be run from a Registration screen." ]
   Exit Script [ Text Result: $null ]
End If

# handle optional behavior
If [ $clear_flag ]
   Set Field [ _GLOBAL::g_Registration_Search ; "" ]
End If

# perform search...
Enter Find Mode [ Pause: Off ]
# ...start with selected event
Set Field [ REGISTRATION::ID_Event ; "==" & $$ID_EVENT ]
Set Field [ REGISTRATION::Is_Registered ; 1 ]

# ...then add search criteria
If [ not IsEmpty ( _GLOBAL::g_Registration_Search ) ]
   Set Field [ registration_ATTENDEE::Name_First_Last ; _GLOBAL::g_Registration_Search ]
End If

# ...and perform find
Set Error Capture [ On ]
Perform Find [ ]
Set Error Capture [ Off ]

# sort results
Perform Script [ Specified: From list ; “iPad: Sort Registration” ; Parameter: ]

Exit Script [ Text Result: $null ]

  1. For the Show Custom Dialog script step, only the Default Button should be specified, with the button text “OK”.
  1. Save and close the script.

Step 4 - Update script to initialize search field

Since the user will be entering text in the search field, you need to create a process to initialize that field each time the user lands on the iPad | Registration List layout. To do this, you will modify the iPad: Go to Event Registration List script.

  1. In the Script Workspace, open the iPad: Go to Event Registration List script.
  2. After the # set selected event portion of the script, add the following steps to initialize the search filter field.

# clear registration search field
Set Field [ _GLOBAL::g_Registration_Search ; "" ]

  1. Save and close the script.

Step 5 - Create search and clear buttons

With the search script in place, now you will create buttons so that the user can both run and clear their search.

  1. Enter Layout mode and navigate to the iPad | Registration List layout.
  2. Add a button to the right of the search field:
    1. Choose the Display only a label option.
    2. Set the label to “Search”.
    3. Configure it to run the new iPad: Search Registration ( clear_flag ) script, with no parameter.
    4. Assign it the Default style.
  3. Duplicate the Search button:
    1. Set the new button label to “Clear”, again with no icon.
    2. It should run the same script, but give it the parameter: # ( “clear_flag” ; True )
    3. Assign it the btn White style.
    4. Set the following hide condition: IsEmpty ( _GLOBAL::g_Registration_Search ). This makes it so the Clear button only appears when search text has been entered.
  4. Resize and arrange the buttons as shown below.
  1. Enter Browse mode to save and review your work.

Step 6 - Review your work

  1. With the file open using FileMaker Pro Advanced on your desktop device, open the Script Workspace and manually run the iPad: Startup script to go to the iPad | Event List layout.
  2. Select an event on the iPad: Event List layout to go to the iPad: Registration List layout displaying the registered attendees.
  3. In the attendee search field, enter the first few letters of an attendee’s name and then click Search. The list should be filtered for attendees matching that text.
  4. Now that you have entered search text, the Clear button should appear. Click the Clear button to clear the search and show all registered attendees again.
  5. Try performing various searches to verify you get the results you expect.
  6. Once you have finished testing iPad functionality on your desktop device, choose the View > Status Toolbar menu to gain access to the FileMaker toolbars again.
  7. Transfer the file to your iPad and open it (or host the file with FileMaker Server and open it remotely). Repeat the above steps to test the filter functionality on the iPad.