4 Replies Latest reply on Jul 3, 2013 4:08 PM by disabled_Luna.media

    How to create a new record with Applescript?

      Dear all,

       

      I am trying to script an Apple Script to find some data records in a Filemaker database and to create new records if the looked up data does not exist. Though code seems to be easy I do not get it to run. What I have:

       

      tell application "Filemaker Pro Advanced" -- FM Pro Advanced 12 is used

       

      go to layout "Companies" of window "MyDatabase" --works

       

      create record --does not work

      go to last record

      set cell "Company" to "Testcompany"

       

      end tell

       

      If I run the script I get a error number -17005 and "create record" ist highlighted.

       

      Does anybody has an idea? And: ist there anwhere a documentation for "Apple script and Filemaker"?

       

      Thanks in advance.

        • 1. Re: How to create a new record with Aplle Script?
          keywords

          What about making a FM script for the create record and set field steps and have you Applescript call that script? Might work.

          • 2. Re: How to create a new record with Aplle Script?

            Well, I want to realize it via Apllescript "only" on the one hand because I do not like "mixed" codes that has to rely that a certaib script in FM is not touched meanwhile, on the other hand it still is a question anyway how to do it with Applescript as it should work correctly.

            • 3. Re: How to create a new record with Aplle Script?
              sporobolus

              on 2013-07-03 24:52 luna.media wrote

               

              I am trying to script an Apple Script to find some data records in a Filemaker database and to create new records if the looked up data does not exist. Though code seems to be easy I do not get it to run. What I have:

               

              tell application "Filemaker Pro Advanced" -- FM Pro Advanced 12 is used

               

              go to layout "Companies" of window "MyDatabase" --works

               

              create record     --does not work

              go to last record

              set cell "Company" to "Testcompany"

               

              end tell

              >

              > If I run the script I get a error number -17005 and "create record" ist

              highlighted.

               

              the code is basically okay; it is making some assumptions, but it can work, the

              problem is not an AppleScript problem, but in the record validation; see the

              help for error number -17005:

               

              <https://www.filemaker.com/12help/html/create_script.13.21.html#1028556>

               

              the solution depends on what validation requirements are being violated; for

              example if a value is required, auto-entering a default value may help (and

              your code can then reset it); it is possible to send data in the create record

              command, but it is rather awkward as you must supply a list of field values in

              creation order, so you may have to jigger the creation order to avoid stomping

              on the values for auto-enter fields such as primary keys

               

               

              ist there anwhere a documentation for "Apple script and Filemaker"?

               

              FileMaker used to distribute a database that served as a reference in the

              application folder, English Extras > Apple Events > Apple Events Reference.fp7,

              but i don't see it in my FMP12A installation; there are lots of examples you

              can google, and some usable reference material

              • 4. Re: How to create a new record with Aplle Script?

                Yey, you must be right. I defined a new simple table without any validation rules and it works there. Therefore I wil have to go through the diffferent validatiion rules to see what I do have to supply or check...  Thanks for the hint.

                 

                At "documentation" I have to say that I did not find much profund information; mostly very basic primers. Well, things will work out step by step...