1 2 Previous Next 19 Replies Latest reply on Feb 1, 2010 11:27 AM by AnnieT

    "Go to Field" NOT Working

    AnnieT

      Title

      "Go to Field" NOT Working

      Post

      Hi there!  I am usign FileMaker Pro 10 on Windows XP with FileMaker Server.

       


      <!-- GALLERYINCLUDE -->I have been working on this problem for several days trying every variable I could think of that might be affecting this issue but have no idea what is going on. 

      Whever I use the "go to field" function in a script it does NOT work. I even tested it with the simplest of scripts...having it be the only step...and the result is always the same. It does not put the user in the specified field...instead it puts them in the field AFTER the specified field.

      Does anyone have any ideas at all about why this would be happening? Is it possible there is a bug? Something I overlooked? Something really simple? Has anyone ever had this problem? I've searched on the web for it but haven't found anything else related to this issue.  I've checked all my table occurences and fields to make sure they match up.

      Here is a detailed example:

      I made something very simple to test it out. A layout with source table "Contacts" with only three fields on it from the same occurence "Contacts."

      All fields can be entered in browse mode (they are name_first and name_last and source). There is no tab order set up. My script has only one step "go to field[Contacts::name_last]" and it is triggered OnObjectExit from the name_first field. When it runs, instead of landing the user in the target field, it puts you in the one after it, in this case the source field.

      I added a pause/resume script step after the "go to field" and it appears that the cursor does actually go to that field, but once the script finishes (I hit continue) I end up in the source field.

       

      What is going on??

       

      Any help would be much appreciated, thanks in advance!

      Annie





       




        • 1. Re: "Go to Field" NOT Working
          Jade
            

          Hi Annie,

           

          This is just a guess, but you may be caught by this issue since your triggered script is exiting the active object.  Is there a trigger on the second field as well?  …And why can you not use tab control instead?

           

          ISSUE: 
          In a pre-event triggered script associated with an object (such as OnObjectKeystroke), FileMaker Pro knows not to execute the script again when the event is replayed as long as the same object is still the active object. If during the triggered script the object is exited and re-entered, and if the script returns true so the event is replayed, then the script will be triggered again endlessly.

          WORKAROUND: 
          Three ways to avoid an endless loop in this situation:

          1. Avoid exiting the object during the triggered script, or
          2. The triggered script should completely handle the event and then return false, or
          3. The triggered script should have smarts in it to avoid exiting the field when it is called the second time.

           

          NOTE: There can be a variety of ways for users to get caught in an infinite loop using script triggers. It is very important that you thoroughly test your solutions before deploying them. 

          • 2. Re: "Go to Field" NOT Working
            philmodjunk
              

            I'm curious to see if this is reproducible.

             

            Make a new blank layout. Use the field tool (don't copy and paste from another layout) to add your fields.

             

            put a button on your field and attach your script to it.

             

            Test and see if you get a cursor in the right field.

             

            There could be a script trigger on your target field so that it kicks in and moves the cursor to the next field.

            The layout could be corrupted (this happened to me once and the only indication, was the cursor jumping to the wrong field after go to field put it where I wanted it).

            • 3. Re: "Go to Field" NOT Working
              AnnieT
                

              Hi Jade,

               

              Thanks for the advice!  It doesn't seem like the issue is with exiting the object and then reentering it and thus inducing a cycle.

               

              There is NOT a trigger on the second field.

               

              I CAN use tab control, but this issue is something that is happening within bigger scripts and so I just created this small one to show an example fo what's going on.

              • 4. Re: "Go to Field" NOT Working
                deltatango
                  

                Annie, once the user has entered the first field, are you using tab to go to the next?

                 

                 This could be why it moves over TWO fields.

                 

                Do you know about setting tab order? In layout mode, in the layout menu, there is a menu item called tab order where you can set the order of fields that filemaker will jump to when you hit tab. 

                • 5. Re: "Go to Field" NOT Working
                  AnnieT
                    

                  Hi Phil,

                   

                   

                  I too wanted to see if it was reproducible, that is why I created this simple action.  I made an entirely new layout, with entirely new fields and an entirely new script.  The only trigger I have is on the first field (name_first). 

                   

                  So from your suggestion....I put a button on the layout and attached the script.  It DID put me in the correct field. 

                   

                  Then I put a trigger on name_first (OnObjecExit) to go to the button....and a trigger on the button (OnObjectEnter) to run the script that goes to the field I want: name_last.  It DID work.

                   

                  But this has huge impications if I can't use a simple go to field step at the end of my scripts.

                   

                  How does a layout become corrupted?  Does it have ramifications throughout the rest of the database?  What is the best way to procede...get rid of the layout or start entirely over in a new file (which would be crazy if I can't copy and past layouts!)?

                   

                  I tried creating a whole NEW file/database and made a new table with three fields and a script.  The button for the script works...but the trigger OnObjectExit does NOT play the script or put the cursor anywhere, it just stays in the first field.  The script can be played form the menu at the top of the screen.

                   

                  Thanks for any more advice, I really appreciate the insight!

                  Annie

                   

                   

                  • 6. Re: "Go to Field" NOT Working
                    philmodjunk
                      

                    I just tested the following script in with an on object exit trigger:

                     

                    Go To field [table::FieldName2]

                    Halt Script

                     

                    (Exit script should work as well)

                     

                    I took both fieldName1 and Fieldname2 out of the tab order and set the script trigger on fieldname1.

                     

                    When I press tab or click outside the field, the cursor pops into FieldName2 as expected.

                     

                    Why you need the extra step:

                     

                    Some script triggers such as OnExitObject trigger before the event and some after. If you don't halt or exit the script, the "next field" event kicks in after your script has completed and this takes you to the next field.

                     

                    BTW, you might want to use OnObjectKeystroke and implement a Go To Field action only if the user presses a key that would normally exit the field such as Tab/Return/Enter. Otherwise, if you are in this field and click a button, the script will drop you in the next field and prevent the button click from taking place.

                    • 7. Re: "Go to Field" NOT Working
                      AnnieT
                         Thanks deltatango, I have experimented both with setting tab orders and removing them completely. Neither helps me out :(
                      • 8. Re: "Go to Field" NOT Working
                        deltatango
                           May I ask why you can't just use tab order instead of scripting onobjectexit? I'm just curious :)
                        • 9. Re: "Go to Field" NOT Working
                          AnnieT
                            

                          Hi Phil,

                           

                          I had tried "exit script" after all of my "go to fields" and it didn't help.  I also tried OnObjectKeystroke using a tab and keep getting the same results....it all sounds very logical of course and I know it SHOULD work.

                          • 10. Re: "Go to Field" NOT Working
                            AnnieT
                               I CAN just use the tab order...but this is just a sample that I made up to illustrate the problem that I am having in larger scripts where the go to field is not working properly.  I use this example to show that even in a very simple case where it SHOULD work, it ISN'T.
                            • 11. Re: "Go to Field" NOT Working
                              mrvodka
                                 Why dont you post the file as comment asked in the other forums?
                              • 12. Re: "Go to Field" NOT Working
                                philmodjunk
                                  

                                AnnieT wrote:

                                Hi Phil,

                                 

                                I had tried "exit script" after all of my "go to fields" and it didn't help.  I also tried OnObjectKeystroke using a tab and keep getting the same results....it all sounds very logical of course and I know it SHOULD work.


                                 

                                Try Exit Script[False]
                                • 13. Re: "Go to Field" NOT Working
                                  AnnieT
                                    

                                  Hi John,

                                   

                                  Thanks I didn't realize there was another response there...and I hope it is ok to be posting the same issue to multiple sites...I will post the file on Monday when I'm back in the office with it...thanks! 

                                   

                                  Annie 

                                  • 14. Re: "Go to Field" NOT Working
                                    Radcon
                                      

                                    This is very similar to the problem I was having.  There are some very subtle things going on with script triggers that the script writer needs to understand.  I don't.

                                    In my case,  MikeyG79 pointed out that I didn't even need the Go To Field step to do what I wanted.  If you are curious about the solution that worked for me, see here.

                                    1 2 Previous Next