4 Replies Latest reply on Jul 4, 2017 3:10 AM by keywords

    Problem with Global Dates and scripting

    MichaelCotterill_1

      I am using the following script to find records that fall within a range of dates

       

      Go to Layout

      Show all records

      Enter Find Mode [pause off]

      Set Field [ Flight Details::Date ; Flight Details::GSD & "..." & Flight Details::GED ]

      Perform Find [ ]

       

      In the above all fields for the layout are from the Flight Details table.

      the search is triggered by a button which is manually activated after filling in the Global Start Date (GSD) and Global End Date (GED).

      Despite this the search appears to retain the original search dates even after I have entered new GSD and GED values and activated the button again.

      Should there be an extra step to possibly clear old find results? I thought I was doing that by Showing All Records.

      Any advice appreciated

        • 1. Re: Problem with Global Dates and scripting
          ChrisJohnston

          At the top of your script a global can (and alot of time should) be cleared out by like so.

          Set Field [Flight Details::GSD; ""]
          Set Field [Flight Details::GED; ""]

           

          But you say you manualy enter your dates... hmm... could it be some where else that they need to be cleared? Is that the whole script you show?

          the search is triggered by a button which is manually activated after filling in the Global Start Date (GSD) and Global End Date (GED)

          Could this button be doing something that is retaining the value? Does it run a script where you should clear you global values?

          • 2. Re: Problem with Global Dates and scripting
            ChrisJohnston

            Also you refer to your field "Flight Details::GSD" as global. But it is really a global (one value for all records)?

            • 3. Re: Problem with Global Dates and scripting
              MichaelCotterill_1

              Hi Chris

               

              Thanks for the help.

               

              I returned to the program after a little while and found that I also had a constrain find and it had kept the original values in its string of commands. Not sure why but I took it out and all was well. The fields are indeed global, but I think for aesthetics I might take your advice to clear them each time.

               

              Many thanks

               

              Michael

              • 4. Re: Problem with Global Dates and scripting
                keywords

                I doubt that the Constrain had anything to do with the issue you are reporting. It all be, as already pointed out, that global fields retain their value until altered until your current session ends. Even then, if the file is unhosted global values will remain as they were when last closed. The approach suggested by Chris of clearing them when not needed is sound not just "for aesthetics" but also to avoid confusion. In your script you could include two steps to clear the globals (Set Field to "") after the Find has been performed. Global fields used for temporary service purposes like this should be treated the same way as global variables—only keep them as long as needed.