4 Replies Latest reply on Feb 28, 2017 8:13 AM by dsvail

    Basic applescript problem

    csgnyc

      Not new to applescript, but new to scripting Filemaker.  Having a basic problem.  If I script

       

      tell application "FileMaker Pro Advanced"

        set thedatabase to database "XYZ"

        set cell 3 of record 2 of thedatabase to "1981"

      end tell

       

      then everything's fine -- the third item of record 2 becomes "1981"

       

      However, if I script

       

      tell application "FileMaker Pro Advanced"

        set thedatabase to database "XYZ"

        set therecord to record 2 of thedatabase

        set cell 3 of therecord to "1981"

      end tell

       

      I get a "Can’t set «class ccel» 3 of {the current cells of record 2}

       

      Any idea what I'm doing wrong?

       

      Ideally I want to write a script that enters data into the fields of the current record.  Using "current record" doesn't seem to help.

       

      Thoughts would be appreciated.

        • 1. Re: Basic applescript problem
          gdurniak

          Very interesting

           

          I do not see an Applescript "go to record" command

           

          This should work:

           

          tell application "FileMaker Pro Advanced"

              tell record 2

                set cell 3 to "1981"

               end tell

          end tell

          • 2. Re: Basic applescript problem
            TonyWhite

            This works...as long as there is a record 3 in the found count/set (tested on FileMaker 11 and FileMaker 15)

            tell application "FileMaker Pro Advanced"
                 -- tell database 1
               
            go to record 3
                 -- end tell
            end tell


            Tony White

            • 3. Re: Basic applescript problem
              TonyWhite

              This works (tested on FileMaker 15)

              tell application "FileMaker Pro Advanced"
                   -- tell database 1
                 
              go to record 3
                   -- delay 1 or .1 sometimes needed sometimes not
                 
              set cell "my_field" of current record to "foo" -- field must be on layout, not be a date field, etc.
                  -- end tell
              end tell


              Tony White

              • 4. Re: Basic applescript problem
                dsvail

                how about trying to initiate the apple script from FileMaker using script step Perform AppleScript ... set the result to a global field in FileMaker and then have FileMaker set the correct record /and field.