3 Replies Latest reply on Aug 3, 2012 9:49 PM by philmodjunk

    Keeping found records in script

    lbellino

      Title

      Keeping found records in script

      Post

      I'm new to creating scripts and I created one with help from an associate. I have a few layouts that has a field that shows the record status "active or inactive" (same field used in different layouts) and the script I created will find the active records and sort them ascending. I'm including an image of how it's set up. This works well until I do a find of a cretain set of records, that I want to keep when I got to one of the other layouts that shows the same records that I found. With the script, it automatically, shows all the active records again. Is there a way to keep any finds that I do, while keeping this script associated with these layouts? Or update the script to show that if I do a find, that it keeps the found set and if I don't do a find, it still shows all the active records and sorts?

      Goal here is to keep the found records in other layouts, if a find is being done. If not, it still runs the script to show the active records and sorts them ascending, like I currently have it.

      script1.PNG

        • 1. Re: Keeping found records in script
          philmodjunk

          "under the hood" info:

          All layouts that refer to the same table occurrence (a table occurrence is a "box" used to define relationships in Manage | Database | Relationships ) in Layout setup.... | Show Records from, will share the same found set, sort order and current record within a given filemaker window.

          This gives you two options:

          1) Select a table occurrence and click the duplicate button (two green plus signs) to make a new occurrence for the same table. Create a layout based on this new occurrence. Have your script perform it's finds, sorts etc on this layout and the found set changes will not affect what you see on your other layouts so long as they do not refer to the same table occurrence. This may require duplicating additional table occurrences and linking them in relationships identical to the current layout were you perform this find if you need references to related data.

          2) Open a new window (this can be a hidden window) and perform the find in it. This can create windows resize issues if your database is open on a windows system and has windows maximized--which is why I usually use option 1, but it avoids the extra design work needed to create that duplicate occurrence and possibly additional relationships. You must also be careful not to trip over "edit locks" if you have a record open for editing in window 1, any attempts to modify the data in that record in window 2 will not work and you'll get an error message that the record is locked. This can usually be avoided by commiting records in Window 1 before opening window 2.

          • 2. Re: Keeping found records in script
            LaRetta_1
            You can also set a global variable when script runs then have your layout triggers look for this variable and only run if it's value is 1.
            • 3. Re: Keeping found records in script
              philmodjunk

              Yep, Use that method frequently.