9 Replies Latest reply on Oct 31, 2013 3:53 PM by deathrobot

    onObjectEnter not always working

    deathrobot

      Title

      onObjectEnter not always working

      Post

           I have a field with an onObjectEnter script trigger. I seem to be having some strange behavior. Namely, if there is data in the field, the script is triggered. If it is empty, the script is not triggered. Is this normal behavior?

           Thanks,
           Michael

        • 1. Re: onObjectEnter not always working
          philmodjunk

               That does not appear to be normal behavior.

               Can you describe what you are doing in more detail?

               What does the triggered script do?

               If you create small, brand new test file, can you get the same behavior in it?

          • 2. Re: onObjectEnter not always working
            deathrobot

                 Hi Phil,

                 On your suggestion, I started by making a brand new file with just the basics of what I'm trying to achieve, and everything is working properly. So, I'm obviously doing something to muck up the solution. Here's some more detail:

                 • One field shows the id of a related table
                 • A second field shows the "name" from that same related table, and sits on top of the id field
                 • The top field has the checkmark to allow entering the field in browse mode
                 • The top field has an onObjectEnter script trigger that;

                   
            1.           Grabs some data from the script parameter
            2.      
            3.           Checks for various key combinations
            4.      
            5.           If none are being held, it goes to the first field (by object name) and exits the script

                 If the two fields already contain data, this works fine. If they are empty, the script isn't triggered; when I turn on script debugger and click on the field, nothing happens.

            • 3. Re: onObjectEnter not always working
              philmodjunk

                   The simplest solution is to clear the check box for permitting browse mode access on the name field, but then I have no idea what your script is supposed to do besides putting the focus on the drop down list field (which can't have the arrow option enabled or the list won't automatically deploy when you put the focus on it with your script.)

                   You may need to post the actual script.

                   To post a script to the forum:

                     
              1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
              2.      
              3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
              4.      
              5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
              6.      
              7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
              • 4. Re: onObjectEnter not always working
                deathrobot

                     Hi Phil,

                     I want the top field to change color on hover, which is why I have the field enterable in Browse Mode. I also want to use the field in Find Mode, which is why it's not a button. Here's the script, but when I'm using the script debugger and click on the top field, NOTHING happens when it's empty; the script is not triggered at all. If the field has data in it, it IS triggered:

                      

                # First parse out the script parameters using the DeclareVariables custom function

                Set Variable [ $var; Value:DeclareVariables ( Get(ScriptParameter) ) ]

                # Check to see if the command button is being pressed

                If [ Get ( ActiveModifierKeys ) = 16 ]

                # If it is, go through a series of "if" statements to see where we need to go, and then go there

                     If [ $relatedTable = "People » Projects" ]

                               Go to Related Record [ From table: “People » Projects”; Using layout: “People: Detail” (People) ]

                          Else If [ $relatedTable = "Company » Projects" ]

                               Go to Related Record [ From table: “Companies » Projects”; Using layout: “Companies: Detail” (Companies) ]

                          Else If [ $relatedTable = "Companies » People" ]

                               Go to Related Record [ From table: “Companies » People”; Using layout: “Companies: Detail” (Companies) ]

                          Else If [ $relatedTable = "Licenses » Songs" ]

                               Go to Related Record [ From table: “Songs » Projects”; Using layout: “Songs: Portal” (Songs) ]

                          Else If [ $relatedTable = "Songs » Competitrack" ]

                               Go to Related Record [ From table: “Songs » Competitrack”; Using layout: “Songs: Detail” (Songs) ]

                          Else

                               Show Custom Dialog [ Title: "Oops"; Message: "Developer error. There is no related table specified. Please make a note and let Michael know and reference \"" & Get ( ScriptName ) & ".\""; Default Button: “OK”, Commit: “Yes” ]

                               Exit Script [ Result: False ]

                     End If

                # Check to see if the command+option buttons are being pressed 

                Else If [ Get ( ActiveModifierKeys ) = 24 ]

                    Show Custom Dialog [ Title: "Warning"; Message: "Clear this field?"; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”,

                Commit: “No” ]

                     If [ Get ( LastMessageChoice ) = 1 ]

                          Go to Object [ Object Name: $object ] Set Field [ "" ]

                         Commit Records/Requests

                     Else

                          Exit Script [ ]

                     End If

                # Otherwise, open hidden dropdown menu

                Else

                     Go to Object [ Object Name: $object ]

                End If

                Exit Script [ ] 

                      

                • 5. Re: onObjectEnter not always working
                  philmodjunk

                       I don't see the purpose of $Var as you set it to a value and then no part of your script accesses any variable values during execution.

                       What is the purpose of your script parameters?

                       I can guess that the custom function is using Evaluate to set some variables to values but since they aren't used anywhere in the script, it looks odd.

                       Note: look at that part of your script two months from now and you might be asking yourself the same questions. A comment that documents what's going one there now can save you time in the future.

                       Go to Related records script steps do nothing if there are no related records to which your script can go. Is this field a match field used in any of those relationships? That's one possible explanation that I can see here.

                  • 6. Re: onObjectEnter not always working
                    deathrobot

                         Hi Phil,

                         $Var is part of a custom function written by Ray Cologon. It's just used in his custom function which is why it's not referenced elsewhere in the script. The script parameter defines $relatedTable and $object. $relatedTable is used when the user holds down the command key and clicks on the field. This takes them to the related layout instead of opening the dropdown menu. $object is the name given to the dropdown menu field, and when the modifier key is not held, the script is supposed to make that field active.

                         Regarding your last question, the dropdown menu is an match field from a related table. The top field is also from the related table. It's not from the table the current layout is based on. Is that the cause of my issues?

                         Thanks!

                         Michael

                    • 7. Re: onObjectEnter not always working
                      philmodjunk

                           I can't see enough design detail here to tell why it doesn't work. The following general statement that I'm repeating here is one possible explanation given what I can see thus far:

                           Go to Related records is a script step that does absolutely nothing if there are no related records to "go to". If there are no related records, a script will execute as though the GTRR step did not exist in the script.

                           I asked about whether the field is a match field or not because if the match field is empty, there can be no related records to go to for the relationship that uses that match field.

                      • 8. Re: onObjectEnter not always working
                        deathrobot

                             Okay, I see. So if the fields are empty (no related records), I can't enter the top field. Is there a way to trigger the BOTTOM dropdown menu when I click on the blank TOP field? I can trigger it via tabbing, since the bottom field is in the tab order and the top field is not, but ideally I could click on the top blank field and the bottom dropdown would trigger.

                             Michael

                        • 9. Re: onObjectEnter not always working
                          deathrobot

                               Nevermind. I've got it. I didn't realize I could make the field a button and when in Find Mode, have the cursor go to itself.