11 Replies Latest reply on Dec 2, 2009 2:00 PM by Sorbsbuster

    Help w/ search script...

    Rackman

      Title

      Help w/ search script...

      Post

      I have a little search script I use to find records due for follow up.

       

      The problem I'm having with it is if I perform the search and no records meet the search criteria, it brings me back to record number 1 of my 2600+ records database.

       

      I'd like to know if there is a way to modify the script so that if no records match the search criteria, I'm just returned to the record I was last on when I started the search.

       

      Here's the script...

       

      Set Error Capture [On] 

      Enter Find Mode []

      Set Field [IFO Contact Management::Assigned Broker::; IFO Contact Management::gAccount Name]

      Insert Text [Select; IFO Contact Management::FollowUp;"<=//"]

      Perform Find[]

      If [Get ( FoundCount ) = 0]

         Show Custom Dialog ["No Records Found"; "No records were found for the current user."]

         Go to Layout [original layout]

         Show All Records

      End If

      Sort Records [Restore; No dialog]

       

       

       

      TIA for any help with this!

       

      Joe 

        • 1. Re: Help w/ search script...
          raybaudi
            

          Hi

           

          before entering into Find Mode, set a variable $var with the Get( RecordNumber ), so you can return to it ( provided that records will have the same sort and the same found set.)

          • 2. Re: Help w/ search script...
            philmodjunk
              

            A variation on Raybaudi's suggestion is to store the record's primary key in a global field. (A primary key uniquely identifies the record--usually an auto-entered serial number in FMP).

             

            Then you can build a relationship linking the global field to the Key field and use Go To Related Record (GTRR) to put it back as the current record.

             

            To learn more about the GTRR step, see: The Complete Go To Related Record

            • 3. Re: Help w/ search script...
              Rackman
                

              Hello Daniele,

               

              Thank you for your response.

               

              Unfortunately, I did not write this script as I do not know FMP programming.

               

              Could you provide me with the excact code to place in my script?

               

              Thank you again,

               

              Joe 

              • 4. Re: Help w/ search script...
                TSGal

                Rackman:

                 

                Thank you for your post.

                 

                Following is your script with extra lines marked with an asterisk:

                 

                 

                Set Error Capture [On]

                 

                *Set Variable [ $record ; Get ( RecordNumber ) ]

                 

                Enter Find Mode []

                Set Field [IFO Contact Management::Assigned Broker::; IFO Contact Management::gAccount Name]

                Insert Text [Select; IFO Contact Management::FollowUp;"<=//"]

                Perform Find[]

                If [Get ( FoundCount ) = 0]

                   Show Custom Dialog ["No Records Found"; "No records were found for the current user."]

                   Go to Layout [original layout]

                   Show All Records

                 

                   *Go to Record/Request/Page [ $record ]

                 

                End If

                Sort Records [Restore; No dialog] 

                 

                ------

                 

                In the first statement added, we are using the example provided by "raybaudi".  That is, storing the current record to a variable $record.

                 

                In the second statement added, once no records are found, we return to the original layout, show all records, and then go to the original record.  When you select the "Go to Record/Request/Page" script step, select the option "By Calculation..." and enter:   $record

                 

                Let me know if you need additional information or clarification.

                 

                TSGal

                FileMaker, Inc. 

                • 5. Re: Help w/ search script...
                  Rackman
                    

                  Thanks for the info TSGal.

                   

                  I having a problem entering the 'Set Variable [ $record ; Get ( RecordNumber ) ]' line in my script.

                   

                  I'm adding the 'Set Variable' line to the script and using $record in the 'Set Variable Options' Name box. I can't find how to enter the "Get ( RecordNumber )" to the line though.

                   

                  Can you help me with this?

                   

                  Thanks again

                  • 6. Re: Help w/ search script...
                    philmodjunk
                       Type Get ( RecordNumber ) in the next box down in the same dialog box.
                    • 7. Re: Help w/ search script...
                      Rackman
                        

                      Thanks for the reply.

                       

                      when I enter 'Get ( RecordNumber )' in the Value box in the 'Set Variable Options' box, it outputs the entire line in the script as...

                       

                      Set Variable [ $record ; Value:Get ( RecordNumber ) ]

                       

                      I can't get it to output the line without "Value" added in there.

                       

                      When I run the script, it presents the user with a "Specify Number" dialog box which when OK is clicked does take you back to the original record before the search was started.

                       

                      Any way to get this to work without the 'Specify Number' dialog box appearing?

                      • 8. Re: Help w/ search script...
                        philmodjunk
                          

                        The word Value: is supposed to be there. TSGal made a minor error in leaving that word out of her example.

                         

                        Just enter the expression as directed and you'll be good to go.

                        • 9. Re: Help w/ search script...
                          Sorbsbuster
                            

                          "before entering into Find Mode, set a variable $var with the Get( RecordNumber ), so you can return to it ( provided that records will have the same sort and the same found set.)"

                           

                          Would using Get(RecordID) as the variable not get around this?

                           

                          Alan.

                          • 10. Re: Help w/ search script...
                            philmodjunk
                               Go To Record[by calculation] Requires the Record Number, not the RecordID. If we had a Go To RecordbyRecordID script step, then you could use the recordID value.
                            • 11. Re: Help w/ search script...
                              Sorbsbuster
                                 Yup.