1 2 Previous Next 19 Replies Latest reply on Feb 20, 2012 3:33 PM by abbadonnergal

    Tabbing to next record in list view

    abbadonnergal

      Title

      Tabbing to next record in list view

      Post

      So every user under the sun wants to be able to tab through an interface whether or not they are in form view or list view, and most of them don't know the difference. But if I have 3 fields in a list view hitting tab will take me from field 1, to field 2 to field 3 and back to field 1 again. One would assume that a simple script trigger (on object exit) on the 3rd field with 1 Go To Record (next) step would do the trick, but that takes me to the very last record in my found set! And why do I need "Exit After Last" if I'm not in a loop? I've found that sometimes putting a Go to Next Field step either before or after the Go To Record (next) step does the trick, but not always. Here's the specific situation I'm dealing with:

      Inventory Stock Counting Procedure:

      3 fields per record requiring data input, viewed in list view. 1st field = CaseQnty (number of items in a case), 2nd field = CasesInStock (unopened cases), 3rd field = IndividualInStock (items not in cases). The total inventory quantity calculates itself. IndividualInStock can equal the final amount if the first 2 fields are blank, or can equal field 1 * field 2 + field 3. Depends on if the person counting stock needs Filemaker to help him/her count. So...

      If the user selects sets a global field (zgCountBy) to "Case", the user can let Filemaker calculate the quantity in stock based on all 3 fields. If the user wants to do his/her own math and input 1 value, he/she sets zgCountBy to "Individual". I have script triggers (on Object Enter) on the first 2 fields that evaluate whether or not the zgCountBy field is set to "Case" or "Individual". So if it's set to "Case" it exits the script and allows data input, but if it's "Individual" it goes to the 3rd field.

      After the user has input data for the first record I want the Tab button to take them to the next record. If zgCountBy = "Case" it should take them to the 1st field in the next record. If zgCountBy = "Individual" it should take them to the 3rd record. I've tried several different approaches, but I can't seem to figure out how to get it to work when zgCountBy is set to "Individal". Here is the script:

       If [INY__Inventory::zgCountBy = "Case"]

      Go to Next Field

      Go to Record/Request/Page [Next; Exit after last]

      Else

      Go to Record/Request/Page [Next; Exit after last]

      Go to Field [Select/perform; iny_STK__StockTakeCreate::IndividualInStock]

      End If

      When zgCountBy is set to "Case" this works beautifully, tabbing through field 1, 2, 3 and to field 1 of the next record. Without the Go to Next Field step, the user goes to field 3 in the next record. With that step, it first goes back to field 1 and then to field 1 in the next record. When zgCountBy is set to "Individual" the script trigger on field 3 sends the user flying to the last record in the found set and goes to field 1, instead of the field I indicated in the script. The tab order is set to fields only and there are only 3 steps (on fields 1, 2 and 3). I can't seem to crack this one :-(

       

       

        • 1. Re: Tabbing to next record in list view
          philmodjunk

          I'd use this script with the OnObjectKeystroke trigger set on the rightmost field:

          IF [ Code ( Get ( TriggerKeystroke ) = 9 ]
              Go to record/Request/page [next]
              Exit Script [false]
          End If

          This script will only move you to the next record if the tab key is pressed. If the user exits the field by clicking another field on the layout, it won't trip and put the user where they didn't intend to be. You can expand the expression if you want Enter and Return keys to also advance the user to the next record. Looke up "Code" in fileMaker help to learn the needed character codes.

          • 2. Re: Tabbing to next record in list view
            abbadonnergal

             Thanks! OnObjectKeystroke seems to be much better practice. However, I'm still being hurled to the last record in the found set for some reason, when "Individual" is selected... "Case" works just fine". Here is the adjusted script:

            If [Code (Get (TriggerKeystroke) = 9) and INY__Inventory::zgCountBy = "Case"]

            #Works perfectly

            Go to Record/Request/Page [Next; Exit after last]

            Go to Next Field

            Exit Script []

            Else If [Code (Get (TriggerKeystroke) = 9) and INY__Inventory::zgCountBy = "Individual"]

            #Goes to last record in found set

            Go to Record/Request/Page [Next; Exit after last]

            Go to Next Field

            //Go to Field [iny_STK__StockTakeCreate::IndividualInStock]

            Exit Script []

            End If

            The disabled step doesn't seem to do anything when enabled, but I would like to land the user in that field somehow in the NEXT record, not in the last record :-( Why would it take me to the last record if I'm not in a loop? On top of that, if I don't Exit after last I get stuck in a loop...

            • 3. Re: Tabbing to next record in list view
              philmodjunk

              You do not need Exit after last as that only applies to loops. And this should not take you to the last record if you are using the OnObjectkeystroke trigger and have disabled the onObjectexit trigger.

              You also need Exit Script [FALSE] not Exit Script [] (this is the one exception in FileMaker that I know of where False and No value are not equivalent.)

              The exit script [false]

              cancels out the tab operation to keep it from happening as this can interfer with where your script leaves the cursor.

              Why do you need an Else IF instead of IF?

              And you should test for the tab key before attempting to go to the next record as you do not want to change records unless the tab key was pressed.

              Your original script jumps to the last record because it trips itself over and over again by triggering exit events on the field.

              You do need to use:

              IF [ Code ( Get ( TriggerKeystroke ) = 9 ]
                  Go to record/Request/page [next]
                  Go to Field [[iny_STK__StockTakeCreate::IndividualInStock]
                  Exit Script [false]
              End If

              assuming that iny_STK__StockTakeCreate::IndividualInStock is the first field in your row.

              • 4. Re: Tabbing to next record in list view
                abbadonnergal

                 Hmmm... I think I implimented your suggestions correctly, but it still isn't working. Here is the new script with updated comments:

                If [Code (Get (TriggerKeystroke) = 9) and INY__Inventory::zgCountBy = "Case"]

                #Works perfectly (Goes to next record and skips the CaseQNTY field).

                Go to Record/Request/Page [Next]

                Go to Next Field

                Go to Next Field

                Exit Script [Result:False]

                If [Code (Get (TriggerKeystroke) = 9) and INY__Inventory::zgCountBy = "Individual"]

                #Doesn't go to next record. Simply puts the user back into the first field.

                Go to Record/Request/Page [Next]

                Go to Field [iny_STK__StockTakeCreate::IndividualInStock]

                Exit Script [Result: False]

                End If

                End If

                Maybe I'm doing the Exit Script [FALSE] wrong, because obviously it reads differently in the script step. I used Else If before because I'm still a Filemaker noob and still can't figure out when I should use Else If :-) So like my Comment says, the Go to Record Next step seems to not be working at all now :-( And no, the IndividualInStock field is not the 1st field in the row, it's the 3rd. Perhaps that is shooting me in the foot, but it is in a logical location for data input.

                • 5. Re: Tabbing to next record in list view
                  philmodjunk

                  Here is a demo file. Compare it to yours. Look for any layout based script triggers such as OnRecordLoad that may be affecting the script's execution.

                  http://www.4shared.com/file/hHdlzxGL/TabToNextListRecord.html

                  • 6. Re: Tabbing to next record in list view
                    abbadonnergal

                     Thanks for the demo file! It makes perfect sense to me. Here's what's killing me. If I'm in the 3rd field and I simply hit the Next Record button, I get into the field I need. The following script works perfectly when assigned as a trigger (On Object Keystroke):

                    Go to Record/Request/Page [Next]

                    Exit Script [Result:False]

                    And I don't need to specify which field I should land in because it keeps me in the same field. However, as part of the larger script, in conjunction with all of my If logic, it doesn't take me to the next record. And calling the 2-step script, after the If statement for zgCountBy passes, doesn't work either.

                    • 7. Re: Tabbing to next record in list view
                      abbadonnergal

                       When I switch around the If statements (evaluate zgCountBy for "Individual" first and "Case" second) it takes me to the next record when "Individual" is set, but not when "Case" is set.

                      • 8. Re: Tabbing to next record in list view
                        philmodjunk

                        Do you have any other script triggers defined for this layout?

                        My best guess is that you have another trigger performing another script. A script can trip script triggers when it executes. That's why on of yours went all the way to the last record.

                        Open Layout setup... and click the script triggers tab and see what is selected.

                        OnRecordLoad, for example, will be tripped by any script trigger that does a go to next record step.

                        An OnObjectEnter trigger on this same last field will also be tripped when go to next record takes you to the next record and the cursor enters the field of this next record.

                        The easiest way to check for such issues is to use the script debugger in FileMaker Advanced to step through your script. If it's tripping any triggers, you'll see those scripts pop up in the debugger when they are tripped.

                        • 9. Re: Tabbing to next record in list view
                          abbadonnergal

                          Eureka! Why I didn't use the debugger at first is beyond me, but I did after you suggested it :-) I noticed in the debugger that if the first If statement didn't pass, it just went to the end of the script, skipping over the second If statement! Ironically, replacing it with an "Else if" or simply an "Else" did the trick. I still don't understand the difference between the two, i.e. why Filemaker skips over the second If statement. Here's the final script that seems to work perfectly:

                          If [Code (Get (TriggerKeystroke) = 9) and INY__Inventory::zgCountBy = "Individual"]

                            Go to Record/Request/Page [Next]

                            Exit Script [Result:False]

                          Else If [Code (Get (TriggerKeystroke) = 9) and INY__Inventory::zgCountBy = "Case"]

                            Go to Record/Request/Page [Next]

                            Go to Field [iny_STK__StockTakeCreate::CasesInStock]

                            Exit Script [Result: False]

                          End If

                          Thanks again Phil!!!

                          • 10. Re: Tabbing to next record in list view
                            philmodjunk

                            Debugger and data viewer can be a major migraine preventor for me...

                            If you have this type of structure in your script:

                            If [Boolean expression 1]

                               Script steps

                               If [boolean expression 2]

                                   Script steps

                               End IF

                            End If

                            Then all steps from the first If to the last End IF will be skipped if "boolean expression 1"  is not true. That's how it's supposed to work. The indenting you see in the script editor can be a very helpful visual cue to see what set of steps will or will not execute when the If expression evaluates.

                            The Else and Else If steps are there so you can set up sections of your script that only execute if the expression inside the If brackets is false.

                            • 11. Re: Tabbing to next record in list view
                              abbadonnergal

                               That makes sense... But is there anything wrong with my current Else If approach?

                              • 12. Re: Tabbing to next record in list view
                                philmodjunk

                                Not that I can see, but I have no way of knowing how the values "case" and "individual" in your INY__Inventory::zgCountBy field affect your work flow.

                                What you have will do one thing if the tab is pressed and you have "individual".

                                It does  different steps if the tab is pressed and you have "case".

                                In both of these cases, Exit Script [false] the action that would normally take place when the tab is pressed.

                                If neither of those are the case, the script exits without doing anything and you see the normal default result of pressing whatever key was pressed on your screen.

                                • 13. Re: Tabbing to next record in list view
                                  abbadonnergal

                                   BTW, it seems like the On Object Keystroke trigger doesn't really allow any data to be input. On Object Validate seems to work better.

                                  • 14. Re: Tabbing to next record in list view
                                    philmodjunk

                                    Better check that. The demo file allows you to enter data in each field.

                                    The only time it should block the keystroke is when Exit Script [false] executes.

                                    1 2 Previous Next