1 2 Previous Next 19 Replies Latest reply on Nov 5, 2009 1:41 PM by curt

    specifying find request

    johnhorner

      Title

      specifying find request

      Post

      i am trying to specify a find request as part of a script and was previously trying to place a field (or, more precisely, the contents of a field) into the criteria box without success (meaning that i was trying to have filemaker find records where the value in the selected target field matched the value in another field that happended to be a calculation field).  it is my understanding that whatever you enter into the "criteria" window" is merely treated as plain text in performing the find.  if this is the case, what is the purpose of the "insert symbol" button.  for example, i placed "==" (which is described as "field contect match" in the insert symbol list) but when i type "== fieldname" in the criteria, it simply places exactly that text "==fieldname" into the target field rather than placing the contents of "fieldname" into the target field for the purposes of the search so, naturally, no matching records are found.  how is this supposed to work?  does anyone know?  please advise... thanks!

        • 1. Re: specifying find request
          Orlando
            

          Hi johnhorner,

           

          Welcome to the forum.

           

          It sounds to me like you are on the right track but your criteria is slightly wrong. Are you using the Perform Find script step and specifying the criteria there? What might be best is for you to use the Enter Find Mode and Set Field script steps, and if you want to search on the value of a field in the current record you will need to store that value in a variable first, unless it is a global.

           

          The steps to preform the find would look something like this:

           

            #

            Set Error Capture [On] 

            Set Variable [ $SearchRequest ; TABLE::Fieldname ] 

            #

            Enter Find Mode [] // Deselect 'Pause' 

            Set Field [ TABLE::SearchField ; "==" & $SearchRequest ]

            Perform Find [] 

            # 

            #// Check result and if no records found alert user.

            If [ Get ( FoundCount ) = 0 ]

              Show Custom Dialog ["Message" ; "No Records Found."]

              Enter Browse Mode []

            End If 

            #  

           

          Let me know if this helps.

          • 2. Re: specifying find request
            raybaudi
              

            Hi johnhorner


            "it is my understanding that whatever you enter into the "criteria" window" is merely treated as plain text in performing the find"

             

            Yes

             

            "if this is the case, what is the purpose of the "insert symbol" button.  for example, i placed "==" "

             

            The purpose is find records with that field containing exactly a "fixed" word


            To make a more flexible Find you have to use 3 steps:

             

            Enter Find Mode [ ]
            Set Field [ MyField ; AnotherField ]
            Perform Find [ ]

            • 3. Re: specifying find request
              johnhorner
                

              hey orlando,

               

              thanks!  i am a long-time novice, if there can be such a thing.  i have been using filemaker for a while but have clearly only scrathced the surface. so your reply actually helped teach me a few things i didn't even know i didn't know, and as a result generated another whole set of questions.  yes, i was using the perform find script step, and now i understand how that works much better as well as how to use the enter find mode/set field/perform find method to execute finds.  but know that i understand how to use this method, i am curious why you would really ever need to use the perform find with specified criteria.  it seems less versatile.  anyway, you also opened my eyes with regard to variables.  i still don't understand exactly what they are, but it seems like the equivalent of a global field, i am curios how these differ from global fields?  i will look into this more in the knowledge base.  i also noticed that sometimes they are defined using a single "$" and in other places using a double "$$". i also am not familiar with using the error capture feature.... this also is something i will have to investigate more.  anyway, as i say, i have learned a great deal from your reply, perhaps most important of which is how much i need to learn!  thanks again.

               

              all the best,

               

              john h.

              • 4. Re: specifying find request
                johnhorner
                  

                hey daniele,

                 

                thanks for the reply.  it seemed kind of silly that they had a button to insert a symbol into the criteria box just to save you from having to type the symbol so i suspected it did more than that but i understand now that my suspicions were unfounded.  the only question i have now is why anyone would use the specify find criteria method inside of the perform find script step instead of using the 3 step method you outlined as your method seems so much more useful.  maybe it is a leftover feature from an earlier version?  i appreciate your help.

                 

                john h.

                • 5. Re: specifying find request
                  raybaudi
                    

                  "maybe it is a leftover feature from an earlier version ?"

                   

                  No, it is a recent feature.

                   

                  "why anyone would use the specify find criteria method inside of the perform find script step instead of using the 3 step method"

                   

                  An example ( but there are many more ) because, using a button, you can give it a whole script OR a SINGLE step.

                   

                  If you create a button to FIND records with an empty field you can give it a single step:

                   

                  Perform Find [ TheField ; criteria: = ]

                  • 6. Re: specifying find request
                    Orlando
                      

                    Hi John, glad I could help and point out some things you did not already know.

                     

                    With the Perform Script step Daniele is right, it is great for performing static finds on buttons, and also when doing a script, if your search only requires a Symbol or static text, Can be easier to use for simple finds.

                     

                    Variables are great and you are right, they are very much like global fields except there is no physical field in the database table. So for scripts and storing values in your session they are very useful, however single dollar variables "$" are Local to the script you are running, so not accessible in any Sub-scripts and are cleared when the script ends. And double dollar variable "$$" are Global and are active throughout the users session, but only the file they are set in, not the FileMaker session, and are cleared when the file is closed or you set the value to Null.

                     

                    The difference between Variable and Global Fields is that Variable cant been accesses in other files, or sub-scripts and you cant setup relationships with variable, as they have no physical presence in the database structure so you will still need to use globals for these.

                     

                    And finally the Error Capture script step, I added this in the search script because if there were no records that match your request, if you did not set Error Capture to On, then FileMaker would return a standard message Saying "No records match this set of find requests" and give the user to Cancel, Continue or Modify the search, so by setting error capture to On and using the Get ( LastError ) calculation function, or in this case "Get ( FoundCount ) = 0", you can alert the user and/or modify the outcome appropriately.

                     

                    This is just a rough explanation and I highly recommend you checkout the FileMaker Help for a more detailed explanation and examples. 

                    • 7. Re: specifying find request
                      johnhorner
                        

                      ahhhh, of course.  that makes sense.

                       

                      thanks!

                       

                      john h.

                      • 8. Re: specifying find request
                        johnhorner
                          

                        thanks so much again!  i am already experimenting with variables and getting familiar with the "knowledge base".  i had noticed your custom message at the end of your solution from the previous posting but didn't realize that the error capture part at the beginnning was part of it.  now i understand it better, although i'm sure i will have to script it myself a few times to really get the hang of it.

                         

                        now, at the risk of harrassing you with too many questions, i do have just one final thing thing to ask (unrelated to filemaker).  i notice in the forum on the right side ofthe page there is a yellow icon that says "kudos" and below that sometimes is another green icon that says "solution?".  i am assuming that kudos will give you positive feedback of some sort and that solution means that it solved my problem?  ordinarily i would just click them to try it out but as i am new to this whole forum thing i didn't want to do anything i didn't know how to undo in case it was not what i expected.  if it's what i think i will certainly click them both with pleasure.  thanks for all your explanations and patience.

                         

                        john h.

                         

                         

                        • 9. Re: specifying find request
                          Orlando
                            

                          No worries John, 

                           

                          You have the whole Kudos and Solution? pretty much spot on with that, I think it is good to mark solutions as accepted so who might have a similar problem can easily see that this has worked for you.

                           

                          an about Accepted Solution here http://forum-en.filemaker.com/fm/help_faq#solution_whatis 

                           

                          You can find out more on Kudos, how it all works, here http://forum-en.filemaker.com/fm/help_faq#kudos_whatis

                           

                          Good luck and have fun learning more about FileMaker and do post if you ever need more help or advice.

                          • 10. Re: specifying find request
                            Shipstead
                              

                            Orlando –

                             

                            I would like to do something similar and tried to adapt your script, but couldn’t get it to work.  My goal is to have a user enter a variable or field called “current month” (which is not necessarily the actual current month) and then use that variable or field, along with others already in the table, to find and sort records and to modify layouts.  Right now I have a custom dialog box set up for the user to enter a global field called “Current Month”.  I tried to set up a variable SearchRequest to equal that field, but when I perform the find it’s not narrowing by the current month so I’m obviously doing something wrong.  Any help you could give would be appreciated – I’m still learning the program and am grateful for this forum.  It seems like this would be a common thing to try to do, but I don’t find anything already in the forum.  I’ve copied my scripts below.

                             

                            Sarah

                              

                            “Prepare Consent Calendar”

                            Go to Layout [Jurisdiction Summary]

                            Enter Browse Mode []

                            View As [View as Table]

                            Perform Script [“Set Current Month”] // below

                            Perform Script [“Search on Current Month”] // below

                            Enter Find Mode []

                            Constrain Found Set [Restore] // with specified find requests TABLE::Jurisdiction:[“Direct”] AND TABLE::Review Instrument:[“Consent Calendar”]

                            Sort Records [Restore; No Dialog] // with specified sort order TABLE::Current CFA Number, ascending

                            Go to Layout [Consent Calendar]

                            View As [View as Form]

                            Enter Preview Mode []

                            ……………………….

                            “Set Current Month”

                            Show All Records

                            Enter Browse Mode []

                            Go to Layout [Data Entry Screen]

                            View As [View as Form]

                            Show Custom Dialog [“Select current month”; “Enter month for current meeting (e.g. Feb 09).”; TABLE::Current Month]

                            ……………………….

                            “Search on Current Month”

                            Go to Layout [Jurisdiction Summary]

                            View As [View as Table]

                            Show All Records

                            Enter Find Mode []

                            Set Error Capture (On)

                            Set Variable [$SearchRequest; Value:$TABLE::Current Month]

                            Set Field [$TABLE::Next CFA Meeting Date = $SearchRequest]

                            Perform Find []

                            If [Get (FoundCount = 0)]

                                        Show Custom Dialog [“Message”; “No records found for that month.]

                                        Enter Browse Mode []

                            End If

                            Set Error Capture (Off)
                            • 11. Re: specifying find request
                              TSGal

                              Shipstead:

                               

                              Thank you for your post.

                               

                              Except for a few typos, it looks like everything should work.  I have set something up similar, and I am able to find the correct records.

                               

                              Instead of calling sub-scripts, I have set up the following with comments.

                               

                              Go to Layout [Jurisdiction Summary]

                              Enter Browse Mode []

                              View As [View as Table]

                               

                              # Perform Script ["Set Current Month" ]

                              Show All Records

                               

                              # no need to Enter Browse Mode because you are already there 

                              Go to Layout [Data Entry Screen]

                              View As [View as Form]

                              Show Custom Dialog ["Select current month"; "Enter month for current meeting (e.g. Feb 09)."; TABLE::Current Month ]

                              # the above step automatically puts data into the global field "Current Month"

                               

                              # return to main script

                               

                              # now is when we should initialize the variable

                              Set Variable [$SearchRequest; Value: TABLE::Current Month ] 

                               

                              # perform script "Search on Current Month"

                               

                              Go to Layout [Jurisdiction Summary]

                              View As [View as Table]

                              Show All Records

                               

                              # set error capture

                              Set Error Capture [On]

                               

                              Enter Find Mode []

                              Set Field [TABLE::Next CFA Meeting Date; $SearchRequest ]

                              Perform Find []

                               

                              If [Get (FoundCount = 0 ]

                                 Show Custom Dialog ["Message" ; "No records found for that month. ]

                                 Enter Browse Mode []

                              End If

                               

                              Set Error Capture [Off]

                               

                              # At this point, halt the script.  See if the find is working for you.

                              # If "Next CFA Meeting Date" is a date field, then it may be the reason why nothing is being found.

                              #   Make sure "Next CFA Meeting Date" and "Current Month" are the same field type.

                               

                              # if no records are found above, do you still want to continue with the script?  Just an observation....

                               

                              --------------

                               

                              Let's start with this.  If this works, then remove the "Halt Script" step and continue.

                               

                              TSGal

                              FileMaker, Inc. 

                              • 12. Re: specifying find request
                                KingsPCTech
                                  

                                Orlando,

                                  I was experiencing a similar problem. Your solution was very much appreciated.  It saved me a great deal of time.  Thank you.

                                • 13. Re: specifying find request
                                  wildcat2310
                                    

                                  hi to you filemaker users

                                  i would like some help with this find script i am trying out but i cant seem to get this part of the script ie can any one help me and tell me how i insert this

                                  this is how it goes

                                  set error capture [on]

                                  if [get(windowmode)=0]

                                  #we're in browse mode:enter find mode

                                  if [get(layoutname)="list"]

                                  and so

                                  the part i would like to know how to get in to the script is the #we're in browse mode enter find mode

                                  if any one can help let me know

                                  from colin

                                  • 14. Re: specifying find request
                                    Orlando
                                      

                                    Hi Colin and welcome to the forum,

                                     

                                    The "#" in a script is a comment line, and this can be found in the script step list under Miscellaneous, or the this from the very bottom of the list.

                                     

                                    This is not an actual function that will be run as part of your script, just for you to use to make notes and comments in your script.

                                     

                                    I hope this help.

                                    1 2 Previous Next