1 2 Previous Next 28 Replies Latest reply on Aug 23, 2010 5:06 PM by precociousninja

    Script help for double find and sort

    precociousninja

      Title

      Script help for double find and sort

      Post

      Hi I am still not as good with filemaker as I should be and I am trying to write a script that runs two finds and then sorts the results.  One of the finds and sorts works perfectly yet when I tried to add the second find, I cannot seem to get the script to work.  

      Here is the specific situation.  I need the first find to  find all records that are related to "Band A" while the second find finds all records whose "date is > today"  then I need all the records sorted from today (if no record shows today, then it shows the next date there is a record for) into the far future in order.  

      Right Now, my script looks like this:

      Enter Find More []
      Set Field [show::date_show[">=" & Get ( Current Date)]]
      Set Error Capture [On]
      Perform Find [Restore]
      Sort Records [Restore; No Dialog]
      Go to Record/Request/Page [First]

      I have tried the following find for the script "show:: artist: [Band A]" alone as well as two finds in the find section.  The two being: "show:: artist: [Band A]" as well as "show::date_show: [>=//]"

      The sort is by "date_show" (ascending).  

      I have them set up to be triggered upon layout load yet when I open the layout, I get all records from Band A not just today into the future.  So records whose dates are as old as 1996 are showing up upon layout load.  

      Does anyone see where I am making the error(s)?  Thanks in advance.

      pn

        • 1. Re: Script help for double find and sort
          davidanders

          In find mode you can enter WA into State Field, then click New Request which will create a new find request and enter Jan into month field.

          Clicking Perform Find will first find WA in State and then Find those that contain Jan in Month.

          Multiple Find Requests

          http://help.filemaker.com/app/answers/detail/a_id/5210/~/multiple-find-requests

          • 2. Re: Script help for double find and sort
            precociousninja

            This doesn't help me.  You are describing how to run multiple finds in find mode.  My question is about how to write a script that uses multiple finds.  Basically, I'm not in find mode.  I am writing a script that uses the find function.  Sorry if I am misunderstanding what you are saying. Thanks for trying though.  :D

            • 3. Re: Script help for double find and sort
              philmodjunk

              The process is basically the same:

              enter Find mode[]
              set field [Yourtable::YourField ; //your first criteria ]
              new Record/request
              set field [Yourtable::yourfield ; your second criteria ]
              Set Error capture [on]
              Perform Find[]

              • 4. Re: Script help for double find and sort
                precociousninja

                Okay, So i changed it as Phil mentioned and I am still getting the same results.  I get the records with Band A, but I do not get them in the correct date order.  

                Here is the written script:

                Enter Find More []
                Set Field [show::date_show[">=" & Get ( Current Date)]]
                New Record/Request
                Set Field [show::artist["Band A"]]
                Set Error Capture [On]
                Perform Find [Restore]
                Sort Records [Restore; No Dialog]
                Go to Record/Request/Page [First]

                Where the finds specified for Perform Find are --
                show::artist: "Band A"
                show::date_show: ">=//"

                The script trigger is still on layout load, and when I open the layout i get all all Band A's records but not in the date order I am looking for which I find odd, because I have basically this same script for a different layout without the specific artist portion, and it runs perfectly.  Any ideas?

                • 5. Re: Script help for double find and sort
                  philmodjunk

                  Notice the extra [] in your set field steps. That tells me you've put "Band A" in the wrong place for this to work.

                  to use set field, you have to click both specify buttons in the lower right corner.

                  Click the top button to select the field (show::artist)

                  Clck the lower button to enter the expression "Band A".

                  Do it correctly and you should see:

                  Set Field [Show::Artist ; "Band A"]

                  You might want to remove the Set Error Capture step until you you've got the script working. That way any errors in setting up the find will trigger a dialog to tell you that. (Set Error capture , supresses that dialog and you either use Get ( FoundCount ) and/or Get ( LastError ) to check the results of your find without interrupting it with a dialog that the user will find confusing.)

                  • 6. Re: Script help for double find and sort
                    precociousninja

                    So now the Set Field step shows as you suggest and yet the same problem persists.  I cannot get the dates to show only todays date and forward, instead it shows me all of the records of Band A, not just the current ones.

                    I even removed Error Capture off and I get no error dialogs at all. Thoughts?  

                    Sorry this is not working properly. Is there any other information that I can give that might help solve the problem? I am using Filemaker Pro 10 Advanced if that makes a difference.  

                    Thanks for the help thus far, I feel like I am so close to success.  I really appreciate the Help Phil and David.  Any more you are willing to give I would be greatful for.  

                    Thanks,

                    pn

                    • 7. Re: Script help for double find and sort
                      philmodjunk

                      You appear to have the same problem with your Set Field step for the current date, I see the same extra brackets. Did you correct that step as well?

                      It should be:  Set Field [show::date_show ; ">=" & Get ( Current Date)]

                      • 9. Re: Script help for double find and sort
                        precociousninja

                        Well, I am still at a loss on this one.  Phil/David/anyone if you have any ideas and the time to share my life would be better, if only slightly. 

                        Thanks,

                        pn

                        • 10. Re: Script help for double find and sort
                          philmodjunk

                          I wasn't sure from your last post if that fixed the problem or not...

                          Are you sure date_show is a date field and not a text field?

                          • 11. Re: Script help for double find and sort
                            precociousninja

                            Sorry for the miscommunication.  The date_show field is in fact a date field.  It is also indexed if that makes a difference.  

                            Like I said, I find it very bizarre that the script without the artist section works fine in another layout.  

                            • 12. Re: Script help for double find and sort
                              philmodjunk

                              What layout is "current" when you run the script?

                              Does it refer to "Show" in the "show records from" box of Layout Setup... ?

                              • 13. Re: Script help for double find and sort
                                davidanders

                                Can you manually do the Find?

                                Go to a layout, enter Find Mode, enter Band, New Request, enter date, perform find?

                                If you can't do it manually, normally you can't do it with scripts.  Or so I have found.

                                • 14. Re: Script help for double find and sort
                                  precociousninja

                                  Phil, I am not sure what you mean by which layout is "current" but yes, it does refer to "show" in the "show records from" box. 

                                  David, I can run the find manually in find mode and it works properly.  

                                  The one difference is that since the artist field is a drop down menu, i can just choose "Band A" from the list.  (however getting Band A's records isn't the problem, I am able to get those, it's just getting the records ">=//" that doesnt seem to work in the script).

                                  As of right now this is what the script shows:

                                  Enter Find Mode[]
                                  Set Field [show::artist; "Band A"]
                                  New Record/Request
                                  Set Field[show::date_show; ">= & Get ( Current Date )"] <-the ">=" written here is actually the symbol and not those two characters
                                  Perform Find [Restore]
                                  Sort Records [Restore; No dialog]
                                  Go to Record/Request/Page [First]

                                  When I double click on the Perform Find [Restore] step, I see "Find Recors    /   show::artist: [Band A]" and "Find Records    /  show::date_show: [>=//]" Where the Find Records are the actions and the data to the right of the "/" is the criteria.  I included this because I was afraid that perhaps this was the incorrect part.

                                  Is there anything else I can check?

                                  1 2 Previous Next