10 Replies Latest reply on Sep 4, 2014 1:51 PM by MichaelShearer

    Scripted find



      Scripted find


           I've been trying for 3 days to figure this out. It should be easy. I want to script a find based on another field. Here is what I mean: I type a name into field "Find Me" and it finds the record that matches in field "Club Name". I have tried using find and find matching records. I could use just the "Club Name" field to do the find as well. Either way I can't seem to script it.

           I checked around and can't seem to find the fix.



        • 1. Re: Scripted find

               Define "find me" as a field with global storage so that its value is accessible when your script enters find mode.

               Enter Find Mode [] ---> clear the pause check box
               Set Field [YourTable::Club name ; YourTable::find me ]
               Set Error Capture [on]
               Perform Find [] ---> no find criteria is specified in this step

               This is patterned after the many examples of scripted finds found here: Scripted Find Examples

          • 2. Re: Scripted find

                 Hi Phil

                 Here is what I'm trying to do:

                 I have a club with up to 90 members. Every week they have to make an input to their record. I want to publish to a FM server. When the page opens they will come to the "Find Me" field or like I said they can go into the "Club Name" field. Then I want fm to find their record. I have the inputs setup so all they do is click on buttons. The inputs then go to a different layout and make the entries.

                 Also, what is the difference between a layout and a table?

                 I thought a table was something you setup on a layout.



            • 3. Re: Scripted find

                   The script that I am describing should do exactly what you are requesting.


                        what is the difference between a layout and a table?

                   Tables are one of the fundamental building blocks for setting up the internal structure of a database. A field stores a single item of information such as a name or a date. A group of fields ( a row in a table shown in a table view), make up a record--such as the name, address and other fields to define one Contact. A table consists of many records all of the same design such as a table of contact records.

                   A layout is a means for accessing data in one or more tables defined in your database. FileMaker confuses this distinction in two ways:

                   a) You can define the fields for a table on a layout that is in Table View (Don't think that this was a good idea when FileMaker inc added it as a feature and still don't.)

                   b) Whenever you create a new table in Manage | Database | Tables (I think all new tables/fields should be created in manage database.), FileMaker automatically creates a new layout with exactly the same name as your layout.

                   But you can create many layouts in FileMaker that all refer to the same table and you can give them any name you need to.

                   The "glue" that links a layout to a specific table is called a Tutorial: What are Table Occurrences?. These are the boxes found in Manage | Database | relationships. To further confuse things, FileMaker also creates one new table occurrence with exactly the same name as each new table the same time that it creates that new layout with the matching name. That produces three objects with exactly the same name that are not at all the same thing: Table, Table occurrence and layout.

                   PS. A layout can access data in more than one table if you link those tables to the layout's main table in relationships. This allows you to add fields from related tables--possibly by placing them in a portal to the related table.

              • 4. Re: Scripted find

                     Thx Phil

                     I get the explanation. I'll start making my tables the way you suggest. That should help me with understanding relationships as well.

                     And thanks for the script. I'll give it a try.

                     Nice work, thank you again


                • 5. Re: Scripted find

                       I back Phil with one last stupid question:

                       In the "Set Field" I can only set one table/field. How did you get two?

                       I owe you a couple of beers for this one.


                  • 6. Re: Scripted find

                         You only "set" one field. That's the purpose of Set field, but the expression to the right of the semi-colon is added by clicking the Calculated Result button.

                         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.

                    • 7. Re: Scripted find

                           Ok Phil

                           I have the script you suggested but it didn't do the trick. My guess is I'm doing something wrong. I'm attaching a picture of the two layouts/tables and the script. I'm thinking that I could have the script run after they make their picks. I could use a submit button.

                           The MFC layout is the one they will come to and make their picks. The other layout is one they won't see until all members have made their picks. That will be the second layout with everyone's picks.



                      • 8. Re: Scripted find

                             "didn't do the trick" kinda leaves me in the dark. What exactly does happen when you run that script?

                             But the details in your screenshots provide a clue.

                             Your layout's are based on different tables and the script does not include a layout change and must be performed on a layout based on the MFC table occurrence.

                             Your script thus needs to start with a Go to Layout step that takes you to the second layout before performing the find.

                             But you say that "no one is to see the other layout until everyone had made their picks". That statement would seem to indicate that your script needs to do a lot more than find a record.

                             Also, it may be a simpler design to turn each field that shows a team logo into a button so that choosing team for each "pick" is simply a case of clicking the desired team logo.

                        • 9. Re: Scripted find

                               Well Phil I told you I thought it might be me.

                               I actually made another table because I thought it was needed. I went back and changed to the same table as MFC and it works.

                               I already had the teams as buttons. Thanks for the suggestion though.

                               I'm still going to have to work on the table/layout thing.

                               Thanks for your help and your explanations. Up were a lot of help.

                               Thx again


                          • 10. Re: Scripted find


                            I used your example for a find. It works great. I am concerned that someone might mistype their find and end up in the wrong record. Is there a change I can make to the find to have it find and exact match?