5 Replies Latest reply on Jun 10, 2011 10:05 AM by philmodjunk

    Scripted Find in Global fields replaces Global values…

    andrewggrant

      Summary

      Scripted Find in Global fields replaces Global values…

      Product

      FileMaker Pro

      Version

      FMPA 11 v3

      Operating system version

      OS X 10.6.7

      Description of the issue

      When performing a find via script steps, and setting a Global Field's value, the contents of the Global Field are replaced when the find if performed.

      Steps to reproduce the problem

      Create Global Text field.

      Create script:
      Enter find Mode
      Set Field [ Global Field ] ; Value "Test"
      Perform FInd

      After validation error message, Global Field value has changed to the value entered during Find.

      Expected result

      Expected Find Mode to search but not replace Global value. Expected FM to not allow the value to be entered in a script, or to skip entering the value in Find Mode and return an Error.

      Actual result

      Global field's contents were replaced with find mode value.

        • 1. Re: Scripted Find in Global fields replaces Global values…
          philmodjunk

          I can confirm that this happens in Windows also, but why are you modifying a global field while in find mode? You can't search on a global field as it does not store a value unique to any one record in your table. (You can have 1,000,000 records in your table and the global field will show the same value for every one of them.)

          • 2. Re: Scripted Find in Global fields replaces Global values…
            andrewggrant

            I realize the limitation of Globals. I am currently working through Loops to set a find criteria in all fields in all tables of my DB via script. This causes great difficulty if the Global fields change their values based upon a find criteria.

            I am using a list of values compiled on the fly of all the Tables::Fields in my DB. This necessitates the need for Error Codes for trapping or some sort of precautions built into FMP to prevent important Global fields from having their values changed from a find request.

            When manually attempting this, FMP won't even allow you to enter a Global field when in Find mode. I am looking for similar behavior / precautions in Script steps.

            • 3. Re: Scripted Find in Global fields replaces Global values…
              philmodjunk

              Once upon a time, we didn't have variables. We had to use global fields in all cases where we might use a variable today. Thus it was necessary to be able to modify global fields within a script--even if in find mode. That's why this can be done today due to the need for backwards compatibility.

              It should be possible to avoid the globals pretty easily in your script.

              Method 1: Place all the fields you intend to include in your search of a given table on a utility layout hidden from the user. Use go to Field [next} to cycle through all the fields in a loop. Don't put any global fields on this layout and you won't be modifying any globals while in find mode.

              Method 2: use a naming convention that identifies all fields with global storage by giving them a consistent prefix. Check the field's name and skip it if it starts with the prefix for a global field.

              BTW, I'm curious about the purposes of this "search every field of every table" script. Can you give an example as you how you use such a search?

              • 4. Re: Scripted Find in Global fields replaces Global values…
                andrewggrant

                PhilModJunk,

                The script is a reusable generic script to allow searching of every field in the current Layout. 

                This script allows for a single line search "phrase" which allows the user to add boolean search terms and get results where multiple terms have to shop up in a current record (and layout), not necessarily in the same field. This also allows the user to use "Google-Like" search terms with quotes and "-" to force phrases and omit words and phrases.

                E.g., Search: 'test "search for" -Mike'.

                This search would have to have "test" and "search for" appear in a record without "mike" appearing in any field in the record.

                Again, this allows us to plug this script into any DB and allow fro easy searching "Google-Like" searching of all fields (and records) in the current layout.

                • 5. Re: Scripted Find in Global fields replaces Global values…
                  philmodjunk

                  Hmmm, that sparks a different work around idea. You might keep global fields out of the search if you are using go to field to move from field to field on your layout, if you use behavior settings to deny access to the global fields when you are in find mode. I know that's possible in v11 and think that it is also possible in v10 systems.