3 Replies Latest reply on Nov 19, 2012 4:16 PM by philmodjunk

    Improving on "Perform Find Now" functionality



      Improving on "Perform Find Now" functionality


           My record selector screen allows the user to enter data in up to five fields. If there is no matching data, the entries are lost. I need a way to save the values which have been entered to seed a new record in the database, then move the user back to the detail screen to finish setting up the new account. In this database, over half of the searches will result in no records found, as a music group is building up it's audience.

           I expect that this will entail writing my first filemaker script, saving the values from the screen before running the Perform Find command, (because that wipes out the screen values if no record it found), then switching to new record mode, then pushing the variables back into their places.

           I also need to know how to set the layout's default mode to "find".

        • 1. Re: Improving on "Perform Find Now" functionality

               You can define a set of global fields for this data and have the user enter the data while in browse mode, not find mode.

               Then a script can check for a record that matches the data entered and can then offer to create a new record if no matches were found.

               Here's a sample script using a single global field for the search criteria. In your case, you'd just need to add more fields and corresponding "set field" script steps:

               Enter Find Mode [] ---> clear the pause check box
               Set Field [YourTable::Field1 ; YourTable::globalFieldforField1]  ---> this step will not work unless globalFieldforField1 has global storage specified
               Set Error capture [on]---> keeps error dialog from interrupting your script if no matching records are found.
               Perform Find[]
               If [Not get ( FoundCount ) //no records were found ]
                  Show Custom Dialog ["No matching records were found. Create a new record?"]
                  IF [ Get ( LastMessageChoice ) = 1 // Default button was clicked ]
                      New Record/Request
                      Set Field [YourTable::Field1 ; YourTable::globalFieldforField1]
                  End IF
               End IF


               When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

          • 2. Re: Improving on "Perform Find Now" functionality

                 I'm having trouble following this. If I understand you correctly, I would

                 1.  Add to my contact table GlobalFieldForFirstName and GlobalFieldForLastName.

                 2.  Link the First Name and Last Name text boxes on the contact finder layout to my new global fields.

                 3.  Add a button on the layout linked to a search script.

                 4.  If there is one record found, it will appear on the contact finder layout. If there are more than one matching records, they can be dispayed as list, since I have my finder form set up as a list. 

                 5.  The user can pick one record and go back to the contact detail, and I can set up on field as a button to go to the detail form.

                 6.  If no record is found, can I dispense with the message box and just go ahead and create the new record. The user will see the same thing as if one record was found.

                 Step 2 puzzles me. Do I link the FirstName and LastName text boxes to the global fields or the regular fields in the table.

                 Step 3, do I need a button, or can I tie this script to the existing Perform Find Icon.

            • 3. Re: Improving on "Perform Find Now" functionality

                   1. you could, but you can actually add these fields to any table in your database and this still works. I often define a globals table for all global fields not used in relationships as a way to keep better track of my global fields.

                   2. Yes

                   3. Most likely, A script trigger could be used as well, but given that you have multiple fields a button makes more sense to me. If you have FileMaker Advanced, you do have the option of installing a custom menu where such a script could be used in place of the Perform Find option and then clicking the Perform Find button in the tool bar will perform your script instead of the original menu option.

                   4 & 5. My script did not do that, but that is an option that is easy to add.

                   6. You certainly can, but I recommend against it. Without the dialog, if a user enters incorrect data by mistake, they get a new record even though they do not need one and this can clutter the table with unwanted, incomplete records. The dialog is a final check so that the user can verify that their data is correct before they get a new record.