14 Replies Latest reply on Oct 28, 2010 10:48 AM by ralvy

    Get(RecordNumber) oddity

    ralvy

      Title

      Get(RecordNumber) oddity

      Post

      I want my script to grab the current record number in a List View, stuff it in a global variable, and then scroll the window to the first record. I have these simple steps:

      Set Variable[$$InitialRecordNumber ; Get(RecordNumber)]
      Scroll Window [Home]
      Go to Record/Request/Page [First]

      Seems simple enough to me, but here's what happens. The global variable is correctly set in step 1. But step 3 resets that variable to 1. Why is step 3 stepping on my global variable?

        • 1. Re: Get(RecordNumber) oddity
          philmodjunk

          Is there a script trigger involved that performs this script or another script that modifies the global variable?

          • 2. Re: Get(RecordNumber) oddity
            ralvy

            Yes. It is performed as an OnObjectEnter script trigger. I failed to note that when I run the script just as is, not as a script trigger, it runs fine.

            • 3. Re: Get(RecordNumber) oddity
              philmodjunk

              I suspect that your last step, Go To Record is triggering your script a second time via the OnObjectEnter event and this updates your global variable 1--the record number of your first record. (Go to record will enter the cursor into the same field as was active in the original record on the new record and this is an object enter event.)

              • 4. Re: Get(RecordNumber) oddity
                ralvy

                Well, I was assuming the Go To Record (3rd step) was triggering the scrip again, but Script Debugger doesn't show that. That's what puzzles me.

                • 5. Re: Get(RecordNumber) oddity
                  philmodjunk

                  When I run your script with the debugger, I see it execute twice--which sets the global variable to 1 on the second time around.

                  I changed your script as follows to keep the double execute from happening:

                  If [ Not $$Again ]
                     Set Variable[$$InitialRecordNumber ; Get(RecordNumber)]
                     Scroll Window [Home]
                     Go to Record/Request/Page [First]
                  End IF
                  Set Variable [$$Again ; Value: Not $$Again]

                     

                  • 6. Re: Get(RecordNumber) oddity
                    ralvy

                    I see the second execution now, when I use the Step Inside function in the debugger. I understand the nature of your proposed solution, and have tried it in different situations. Some worked. Some didn't. I have to dig deeper into what's stopping it from working in my particular solution. Thanks as usual, Phil.

                    • 7. Re: Get(RecordNumber) oddity
                      philmodjunk

                      One general work around to keep a script from tripping over triggers you've set in your layout is to keep a second layout to the same table occurrence hidden from the user with no script triggers set. You can go to this layout, manipulate your found set, sort order and current record and then return to your original layout. This doesn't always work, in your case, I think we'd still fire that OnEnter script trigger when we returned to the original layout.

                      Are you sure this is a script you want performed with the OnObjectEnter trigger? That seems an odd trigger for this script, but then I don't have the full picture of what you are trying to set up here.

                      • 8. Re: Get(RecordNumber) oddity
                        ralvy

                        Well, here's the problem that OnObjectEnter is attempting to solve for me. In List View, assume the active record is out sight (say, way down near the bottom of a list of hundreds or records when the scrollbar is at the top of the window). In the header of this layout are global filter fields, like Start Date, End Date, etc. With FMPA 10 and 11, if the current record is out sight like this, the global search fields in the header don't work all that well. For instance, if the Start Date field has a dropdown calendar on it, clicking on the calendar dropdown icon won't work. The same for global dropdown menu fields in the header. To get them to work, I have, until now, used an OnObjectEnter script trigger on each of these global filter fields, where the trigger scrolled the window to Home, and moved the record selector to the first record.

                        But recently I found that my Delete button for any given record in that list wasn't targeting the proper record when these filters were being touched. As you can imagine, the Delete button script was targeting the first record in each such case.

                        Thus my work today on this problem, in this post.

                        For now, I have take off the dropdown calendar icons and dropdown arrows for these global fields, and don't have the scroll script triggers in place in these fields, so the user sees the calendar or dropdown menu popup when they enter the field. I really don't like that, but it gets around this problem of the dropdown calendar and dropdown arrows not working when the active record is out of sight.

                        • 9. Re: Get(RecordNumber) oddity
                          philmodjunk

                          On what Field(s) are you setting this trigger? The fields in the header?

                          Personally, I put delete buttons for list layouts in the body so that my mouse click that performs the delete action also selects the record I want to delete.

                          • 10. Re: Get(RecordNumber) oddity
                            ralvy

                            The OnObjectEnter script triggers are on the global filter fields in the header of the List View layout. The Delete button is in the body of the List View layout, to the far right of all its fields. Later I'm going to have to see why the the Delete button script fails to move the record selector to the desired record when a global filter field is active and it has a scrolling script trigger on it. It does, but the trigger brings it back to record 1 before the delete command is issued. None of this is an issue if I remove the script triggers on the filter fields. In that case, the Delete button moves the record selector to the correct record and deletes the correct record.

                            • 11. Re: Get(RecordNumber) oddity
                              philmodjunk

                              Hmmm, I could be wrong, but that sounds like an On ObjectExit trigger is kicking in when you click the button.

                              Have you tried enabling the debugger when testing that issue?

                              • 12. Re: Get(RecordNumber) oddity
                                ralvy

                                If the global filter field has the cursor in it, of course the scrolling OnObjectEnter script is triggered. The cursor remains there, so the field is still active. If the Delete button for a particular record is touched, the OnObjectEnter script trigger is fired again. That's the problem, as I see it now. I imagine the fact that touching that Delete button moves the record selector is causing the OnObjectEnter script trigger to fire for some reason, even though I'm not touching the filter field a second time. The Delete script doesn't do anything other than issue a Delete command after a Custom Dialog confirms that intention. I'm going to take a break from this for a while, but chime in again if you want. You're always very helpful.

                                • 13. Re: Get(RecordNumber) oddity
                                  philmodjunk

                                  Your post sent me back to my test file where I've been experimenting with this issue. Unfortunately, you are correct, clicking the button in the body triggers an on object enter event on the global field. That's nasty, but the way it works at the moment.

                                  I've been playing with several options here, but so far I haven't found anything that works cleanly.

                                  • 14. Re: Get(RecordNumber) oddity
                                    ralvy

                                    Well, at least I know it's not some hidden thing I have going on over here. I was going to create a stripped down file like you did to make sure of that today.