12 Replies Latest reply on Jun 5, 2012 2:24 PM by steve_ssh

    Worked in FMP 8.5 - Won't in FMP 11

    greginchrist

      Has anyone come across a similar issue? The following woks on FMP 8.5 but nor FMP 11

       

      Any ideas?

       

      on getFieldFromRecord(dbName, tableName, fieldName, matchField1, matchValue)

      tell application "FileMaker Pro Advanced"

      tell database dbName

      --try

      set fieldValue to cell fieldName of (records of table tableName whose cell matchField1 is matchValue)

      --end try

      end tell

      end tell

      return fieldValue

      end getFieldFromRecord

       

      set myResult to getFieldFromRecord("Master DB", "Order", "QcTime", "JobNumber", "12052501")

       

       

       

       

      Thanks in advance, May the Lord Jesus Christ bless you unto salvation through faith in His work on the cross!

        • 1. Re: Worked in FMP 8.5 - Won't in FMP 11
          LyndsayHowarth

          Greg, this is a technical forum not a religious meeting. It has members from all cultures and religions who are respectful of that diversity and do not promote their own brand. Some of us find this kind of extraneous babble offensive.

          - Lyndsay

          • 2. Re: Worked in FMP 8.5 - Won't in FMP 11
            greginchrist

            Lyndsay, that seems quite like bigotry and hypocrisy. You tout about proclaiming respectfulness and diversity, yet you feel it right to rebuke me regarding a greeting or farewell. Sorry "The" Truth is offensive. If you would like to have any further discussion on this nontechnical issue lets please do so via private message. Thanks.

             

            Does anyone have a technical response?

            • 3. Re: Worked in FMP 8.5 - Won't in FMP 11
              patrickdfox

              Just tested and works fine with FileMaker Pro Advanced 11.0v4 and 12.0v1.

               

              What is the error that you are seeing?

               

              Are you using FileMaker Pro or FileMaker Pro Advanced?

               

              Patrick

              • 4. Re: Worked in FMP 8.5 - Won't in FMP 11
                ch0c0halic

                Greg may be telling too much,

                 

                I can't tell from your code if its running as an Application or in the AppleScript Editor or inside FMP's Perform AppleScript step. When you say this works on FMP 8.5 but not 12 I suspect its in the Perform AppleScript step so I'll cover that first.

                 

                When running an AppleScript within FMP you DO NOT use Tell Application "Filemaker Pro". That is why your code is not transportable between versions.

                 

                Also, if the references in the AppleScript are totally within the Current active Windows Table then you do not need to do the Tell Database name either.

                 

                When the AppleScript is running inside FMP it is the Active Application and it knows how to talk to itself. Only use the Tell Application if you have to address a different Application, like the Finder.

                 

                If you are trying to debug the code from the AppleScript Editor then you need the Tell FMP, but remove it when you put it into FMP's Perform AppleScript Step.

                 

                If this is in a compiled app then you have to recompile it for each version of FMP. When compiling AppleScript code it takes the Current Versions AppleScript Library to check the code and then compile it. Guess what? The AppleScript library has change several times between 8.5 and 12. Compiled AS applications are very very unlikely to be upward compatible with either FMP or the OS.

                • 5. Re: Worked in FMP 8.5 - Won't in FMP 11
                  comment

                  greginchrist wrote:

                   

                  Lyndsay, that seems quite like bigotry and hypocrisy.

                   

                  No, it is not. It's a very polite reminder to leave your proclamations at the door and not provoke flame wars. If you want technical answers, stay on technical issues.

                  • 6. Re: Worked in FMP 8.5 - Won't in FMP 11
                    greginchrist

                    Sorry for the broken thoughts here, I just don't know what direction to be investigating.

                     

                    I think I can eliminate my code being the problem. I have been able to use the code and even rewrite the code several different ways and have it function on different data bases. I figure there has to be a different problem.

                     

                    The solution is quite large created by someone else. It has lots of relationships, scripts, custom funtions etc. It is also running on a server I want to say server 8 pro? I will have to check when I am back in the office.

                     

                    I am thinking maybe a relationship could be messing it up... or maybe because it is on a server. Also it works when I use FileMaker Pro 8.5 as my client but not when I run FMP advanced 11. So maybe it has something to do with advanced?

                     

                    I also have created tons of queries I can get tons of things to work until I try to throw in a [whose cell "someCell" = "someValue"]

                     

                    It works fine when I say something like [cell "someCell" of record 4]

                     

                    It seems like the whose statement is breaking it...

                     

                    The error I get is "FileMaker Pro Advanced got an error: Event not handled."

                     

                    I have been banging my head against the wall for literally months.

                     

                    Thanks for any insight you might be able to provide. The Lord Jesus Bless you!

                    • 7. Re: Worked in FMP 8.5 - Won't in FMP 11
                      greginchrist

                      I am leaning toward there being something in the specific database that is causing the issue, maybe a relationship. I copied the database off of the server and tried it locally to no avail. However I can make the same code work with many different databases. So I think it has to be something in the DB file itself.

                       

                      Any idea what would cause this code to render a bad result (this is pretty basic/necessary functionality is it not?)

                       

                      tell application "FileMaker Pro Advanced"

                           cell "cellName" of (every record whose cell "otherCellName" = "someValue") of table "tableName" of database "dbName"

                      end tell

                       

                      //

                      also, regarding the error...

                       

                      "FileMaker Pro Advanced got an error: Event not handled."

                       

                      To me seems to be an error stating that FMP did receive a message however, it could not resolve a response. Does this seem true? If so does this seem like maybe a relationship could be at fault here?

                      • 8. Re: Worked in FMP 8.5 - Won't in FMP 11
                        steve_ssh

                        Hello Greg,

                         

                        Curiosity got the best of me, and I decided to try to reproduce the error over on this end.  I have a few findings to share with you, based on a very small amount of testing.

                         

                         

                        Context:

                         

                        The exact script text I used to mimick what you posted (run from AppleScript Editor):

                         

                          tell application "FileMaker Pro Advanced"

                         

                              return cell "field01" of (every record whose cell "field02" = "hello") of table "Foo" of database "Foo"

                         

                          end tell

                         

                         

                        OS: OSX 10.6.8

                         

                        FMPA: 11.0v3

                         

                         

                         

                         

                        Regarding the error:  "FileMaker Pro Advanced got an error: Event not handled." number -1728

                         

                        I could reproduce this error by setting up any of the following conditions:

                         

                            a) If no such matching record exists in the target table (i.e. no record in table "Foo" has a value of "hello" in field02 )

                         

                            b) If, when I run the AS, the found count in the layout of the active FMPA window = 0  (This will reproduce the error even if a matching record does exist in the table)

                         

                            c) If, when I run the AS, the Table Occurrence underlying the layout of the active FMPA window is based on an entirely different table from the one that we are interested in querying

                         

                         

                        Also worth noting:

                         

                        If I'm reading it correctly, an old forum post seems to have long-ago documented the situation that I'm observing:

                         

                            http://forums.filemaker.com/posts/a4b7164160

                         

                         

                        The author of that post suggests a possible workaround of modifying the Applescript such that you will be nearly guaranteed to have a non-empty found set before executing the script step which targets your desired record.

                         

                         

                        As an example:

                         

                        Modifying my test script above, from within AppleScript Editor, we'd run something like:

                         

                            tell application "FileMaker Pro Advanced"

                         

                                 show every record of table "Foo" of database "Foo"

                         

                                 return cell "field01" of (every record whose cell "field02" = "hello") of table "Foo" of database "Foo"

                         

                            end tell

                         

                         

                        I don't have sufficient background to speak to issues of performance with respect to first setting a found set to *all* records, but that does kind of concern me.  I can vouch for the workaround successfully getting the job done in the simple tests that I've done tonight.

                         

                        Another option might be to try something seemingly more conservative such as:

                         

                            tell application "FileMaker Pro Advanced"

                         

                                show record 1 of table "Foo" of database "Foo"

                         

                                return cell "field01" of (every record whose cell "field02" = "hello") of table "Foo" of database "Foo"

                         

                            end tell

                         

                         

                        In summary:

                         

                        If you haven't yet done so, I'd suggest that you run your tests paying particularly close attention to the context of the currently active FM window when you run the AppleScript.  Is it based on a TO that is relevant to your query?  Does it have at least one record in the found set?  These seem like some worthwhile leads to be able to check up on and either rule out or fix up, as appropriate.

                         

                         

                        Good luck & best,

                         

                        -steve

                        • 9. Re: Worked in FMP 8.5 - Won't in FMP 11
                          briancrockett

                          You seem to have a different definition of truth than the rest of us.

                           

                          Truth is what can be observed, tested and verified. All else is opinion.

                          • 10. Re: Worked in FMP 8.5 - Won't in FMP 11
                            greginchrist

                            I have found the problem but not yet the solution. The guy who set this database up has a second layout open behind the first. Some how this thing always has focus. When I run...

                             

                            tell application "FileMaker Pro Advanced"
                                      name of current layout
                            end tell
                            

                            It will return "Dashboard"

                             

                            This is a layout that used to be a side bar navigation thing. It is still required by a bunch of scripts. I think it was intended or maybe even is used to track records or at least a last record visited. Its table called "Global" has a bunch of global vars defined.

                             

                            I did try the suggestion...

                             

                            tell application "FileMaker Pro Advanced"
                            
                                    show record 1 of table "Foo" of database "Foo"
                            
                                    return cell "field01" of (every record whose cell "field02" = "hello") of table "Foo" of database "Foo"
                            
                            end tell
                            

                             

                            but no luck. I don't know the correct order for calling a layout. I have been trying to nest them like

                             

                            tell application "FileMaker Pro Advanced"
                                 tell layout "Order Entry"
                                      cell "Order_ID" of (every record whose cell "JobNumber" = "someValidNumber")
                                 end tell
                            end tell
                            

                             

                            Also the following code works fine if I close that Dashboard layout...

                             

                            tell application "FileMaker Pro Advanced"   
                                      cell "Order_ID" of (every record whose cell "JobNumber" = "someValidNumber") of table "Order" of database "MASTER DB"
                            end tell
                            
                            

                             

                             

                            Any other suggestions? Also thank very much Steve for that response, it definitely got me going in the right direction.

                            • 11. Re: Worked in FMP 8.5 - Won't in FMP 11
                              greginchrist

                              I think I found the solution.

                               

                               

                              tell application "FileMaker Pro Advanced"
                                        show layout "Order Entry"
                                        return cell "Order_ID" of (every record whose cell "JobNumber" = "12053106") of table "Order" of database "MASTER DB"
                              end tell
                              

                               

                               

                              Thank you everyone for your help! Steve thank you for such an indepth reply! Very much apreciated!

                              • 12. Re: Worked in FMP 8.5 - Won't in FMP 11
                                steve_ssh

                                Glad you got it.  I am away from a machine for a while, and thus unable to play with this, but was pretty sure that there was a simple command to get you on the proper layout first. Congrats on finding it.

                                 

                                Best,

                                 

                                Steve