7 Replies Latest reply on Jul 25, 2016 4:56 AM by TonyWhite

    get name of document


      I regularly change jobs and each new job I rename a copy of my database to reflect the job name

      However each time I do this all of the applescripts I have stop working because they ask for "Tell document "foobar""

      and since I have renamed the document it they dont work and i have to go thru all my code and adjust.


      Is there any way to ask for the current name of the document? then I could set it to a variable and try "Tell document job_name_var"

      I have tried

      tell application "FileMaker Pro Advanced"

          set doc to document name

          display dialog doc

      end tell

      but I get back

      Object not found.


      thanks in advance

        • 1. Re: get name of document
          Johan Hedman

          AppleScript can to fantastic things, but with FM15 you can pretty much do almost anything. Why dont you redo your solution in FM15 and use all new features that comes along with that.

          1 of 1 people found this helpful
          • 2. Re: get name of document


            Ill take a look at it.

            • 3. Re: get name of document
              Markus Schneider

              I would never change the Name of a database file for a new job - just have an attribute for that. When the content should no longer be visible, You could create a clone and start over or make a backup and the delete the data

              Best would be to have just an attribute with all data (migration...)


              We've had customers who used to duplicate&rename their solution-files for each project - sooner or later they

              - wanted statistics over projects/jobs

              - had to use older files for whatever reason (fiscal stuff, FileMaker 2!!)

              - had to migrate all those files to a bew FM version

              - etc

              1 of 1 people found this helpful
              • 4. Re: get name of document

                We often write AppleScript code to a FileMaker global field and then use the Perform AppleScript (Mac OS) script step to run the code that is in the FileMaker global field.

                This has many advantages:

                • The ability to merge in FileMaker object names [Get ( FileName ), Get ( WindowName ), etc.] as in your use case
                • Less brittle code, as you can merge in data using pointers vs. hard coded FileMaker FieldNames
                • Makes debugging easier

                Hope that helps.

                Tony White

                1 of 1 people found this helpful
                • 5. Re: get name of document

                  One trick is to put this name into a field and then use this text in an OnFirstWIndowOpen triggered script to rename the window to the name from the field.

                  1 of 1 people found this helpful
                  • 6. Re: get name of document

                    I have often wondered if this approach would be better.

                    the code is so hidden away that debugging is tricky. I think Ill work on moving my code to fields like you say.

                    I do have one database where I do it the way you suggest and I use fields as variables for the applescript. I use it to run ffmpeg and I can change the quality, size etc etc by changing the data in fields, it works great.


                    what do you mean by pointer?


                    I think I will go with the suggestion from Marcus and never change the name, but your suggestion of AScripts in fields sounds great and same with phils suggestions (as usual!)


                    thanks everyone!

                    • 7. Re: get name of document

                      By pointer I mean reference (which would have been a better choice of word) to a field, for example if you Set Field to a calculation that includes TableOccurrence::FieldName and then change the name of the TableOccurrence or of the FieldName, you will see the calculation update.


                      This is in contrast to something like:

                      set my_var to cell "TableOccurrence::FieldName" of current record, where TableOccurrence::FieldName is a hard coded string (as it is in quotes).


                      Tony White