4 Replies Latest reply on Apr 15, 2012 2:55 PM by Jade

    FM12 Floating Window breaks AppleScript "set cell"

    Jason Wood


      FM12 Floating Window breaks AppleScript "set cell"


      I expected AppleScript to operate on the window with focus, but it seems it operates on the front-most window regardless of which one has been clicked into. This means that the following statement won't work on your current window if you also have a floating window open on the screen that does not have the "fieldName" field.

      set cell "fieldName" of current record to "hello, world!"

      This results in an "object not found" error.

      How would I work around this behaviour? eg: can I expand the above statement to include the name of the window?

        • 1. Re: FM12 Floating Window breaks AppleScript "set cell"

          Hi Jason,

          I don't have 12 yet but try changing your "tell" statement to:

          tell window 2 of application "FileMaker Pro"


          "When you reference a window by index (window 1, window 2..etc ) then windows will considered to be organized according to their order of the screen. Where, window 1 is the frontmost window, window 2 is the window behind the frontmost window and so on, regardless of which document they are related to.  If you want to reference windows according to their relation to a specific document, then you will simply can say (window 1 of document 1, window 2 of document 1..etc) (where, window 1 of document 1 is the first window created for document 1, and window 2 of document 1 is the second window created for document 1 and so on).


          When you're using the current record and current layout properties it's not neccessary to specify the window object.  For example, a statement such as  tell application "FileMaker Pro" to get current record  will return a reference to the current record from the frontmost window. 


          For example, you could say:


          tell window 2 of application "FileMaker Pro"

          create new record with data {"Sue", "Smith"}

          end tell



          • 2. Re: FM12 Floating Window breaks AppleScript "set cell"
            Jason Wood

            That helps. I actually simplified it a little and make the first line simply:

            tell window 2

            I've found that specifying the appication name is unnecessary and results in tons of problems when there are multiple copies on the computer (11 Pro, 11 Adv, 12 Pro, 12 Adv) or after upgrades.

            The drawback is that I'll need to do a test to find out whether the floating window is open at the time.

            My field is a global field by the way... might there be a way to use applescript to set a field that isn't on the current layout?

            • 3. Re: FM12 Floating Window breaks AppleScript "set cell"

              Naming the windows might be a next step. 

              Can you do 

              Tell window named "xxxxx"

              This could simplify your problems. Of course you have to be carefull with your window names.

              • 4. Re: FM12 Floating Window breaks AppleScript "set cell"


                You can probably use go to layout "global_layout_name" followed by either set field "global_name" or set cell "global_name" and the "go to layout "your_original_layout".

                The Apple Events Reference in the English Extras folder of FMP 12's folder may have been enhanced.  It's worth a look.  Choose "Descriptions and Examples" from the Menu and step through the examples.  Please let us know if you find anything of interest.

                P.S. I could only find window window_number not window "your_window_name"