2 Replies Latest reply on Oct 12, 2008 3:51 PM by kbb

    Create record from AppleScript. FMP Advanced

    kbb

      Title

      Create record from AppleScript. FMP Advanced

      Post

      Attempting to add iTunes fields, one at a time to a FMP custom database.  Have been unable to set the correct cell.  I have everything else working great it is only when I attempt to populate the FMP fields that i am failing.  If you can point me in the right direction, it is greatly appreciated.  Below is a log created upon running the following script segment (all of the end statements are there as well as an else that produces an error dialog - these are not executed):

       

      tell application "FileMaker Pro Advanced"

      set thisNewVolRecord to (get a reference to (create new record at table "Music Library Volumes" of database "music library")) 

      repeat with fc from 1 to count of items of volFieldIdList

      if item fc of myVolValues is not equal to "END" then

      if item fc of myVolValues is not equal to "x" then

      set cell of field (item fc of volFieldIdList) of thisNewVolRecord to item fc of myVolValues

      set logVolsWritten to logVolsWritten + 1

      endif

       

      volFieldIdList contains every field ID in the table and contains 63 entries.

       

      myVolValues contains each field from iTunes that I wish to save.  This list is structured to exactly correspond with the fields of the FMP music library.

       

       

      Following is a listing of the log:

       

      tell application "FileMaker Pro Advanced"

      create new record at table "Music Library Volumes" of database "music library"

      record id 3.6777E+4 of table "Music Library Volumes" of database "Music Library.fp7"

      get current cell

      cell id {3.5048E+4, 73.0} of window "Music Library"

      get cell ID {3.5048E+4, 73.0} of window "Music Library"

      "FB0099"

      (*FB0099*)

      set cell of field 3.0 of record ID 3.6777E+4 of table "Music Library Volumes" of database "Music Library.fp7" to "Best Of"

      "FileMaker Pro Advanced got an error: Object not found."

       

       

        • 1. Re: Create record from AppleScript. FMP Advanced
          clemhoff
            

          Hello kbb,

          I think that your error comes from: "set cell of field (item fc of volFieldIdList)...."

           

          // I suppose that "volFieldIdList" and "myVolValues" are "true" AppleScript list


           

          property theExcludeList : {"END", "x"}

          --...
          --...
          other statements here
          --...

          tell database "music library"
              
          go to layout "__TargetLayout__"
              
          set thisNewVolRecord to (ID of (create new record))
              
          tell record ID thisNewVolRecord
                  
          repeat with fc from 1 to (count volFieldIdList)
                      
          set thisVolItem to myVolValues's item fc
                      
          if thisVolItem is not in theExcludeList then
                          
          set cell ID (volFieldIdList's item fc) to thisVolItem
                          
          set logVolsWritten to logVolsWritten + 1
                      end if
                  end repeat
              end tell
          end tell

           

           

          hth

          clem 

           

           



          • 2. Re: Create record from AppleScript. FMP Advanced
            kbb
              

            Clem - that exactly did the trick.  Thank you.  Can you recommend a place that I can learn better these protocols?  I have been studying this (haphazzardly) for several weeks as I learn each of the tools and obviously I don't have it yet.  

             

            Using exactly the code (that works) for the subsequent update for track records, however, the first field consistently gets "object not found".  I am embarrassed to ask again but...  Here is log: 

            go to layout "Music Library Tracks"

            create new record

            record id 4.4114E+4 of window "Music Library"

            get ID of record ID 4.4114E+4 of window "Music Library"

            4.4114E+4

            (*4.4114E+4*)

            go to record ID 4.4114E+4 of layout "music library tracks"

            (*value of fc:  1*)

            (*value of field:  1.0*)

            (*Value of iTunes field: Miriam Makeba*)

            set cell ID 1.0 of table "music library tracks" of database "music library" of record ID 4.4114E+4 of layout "music library tracks" to "Miriam Makeba"

            "FileMaker Pro Advanced got an error: Object not found."