8 Replies Latest reply on Apr 12, 2012 9:31 AM by SteveNoble

    Next Record script not working.

    SteveNoble

      I have set up a simple script trigger to advance to the next record when the date is entered. Instead of going to the next record it goes to the last record. It also goes to the wrong field.

       

      Screen Shot 2012-04-11 at 11.30.22 AM.png Screen Shot 2012-04-11 at 11.36.17 AM.png

       

      I ran debugger and it worked correclty as I went through each step. As soon as I dissmissed deugger, I went to the last record.

       

      I have tried these things with same results

       

      I have dissmissed all layout scripts.

      On Object save instead of On Object Exit

      replaced feild with new field

      removed tab control on field

      Used go to object script instead of go to field

       

      FM11 advanced.

       

      What am I missing?

        • 1. Re: Next Record script not working.
          Stephen Huston

          What is the trigger for this script? onModify, onExit ?

           

          What happens if you add a commit record step at the top of the triggered script to be sure you are not still in a field when you go to the next record?

          • 2. Re: Next Record script not working.
            wsvp

            May have to do with the sorting... If you are entering a date and the found set is sorting on date.  It could wind up in an un-predictable position as soon as the field is saved.  Because the date is changed.

            • 3. Re: Next Record script not working.
              SteveNoble

              There is no date field.

               

              I have tried onExit and on onSave with incorrect behavoir. On modify works correclty however I need to add more than on digit so on modify wont helptme.

               

              I tried a couple experiments:

              onValidate with and without recored commit - went to the next record but wrong field,

              onSave with and without recored commit - went to the next record but wrong field,

              onExit with  record commit - locked up for about 20 seconds.

              onExit without  record commit - went to the Last record and wrong field,

               

              I begining to think I have a corrupted layout????

              • 4. Re: Next Record script not working.
                Stephen Huston

                Trying to reconcile your first post and latest:

                • advance to the next record when the date is entered
                • There is no date field

                 

                However, do you need this trigger script to fire regardless of what is entered in the trigger field, or only if some criteria is met?

                 

                Are there any other triggers on the layout itself which might be interfering?

                 

                Can you post a sample file and provide  clarification as to the desired result you are striving for?

                • 5. Re: Next Record script not working.
                  SteveNoble

                  My first post was wrong. It is a quantity to be entered not date. There is no date field

                   

                  All layout scripts were deleted. No other fields have script triggers.

                   

                  Trigger should fire not matter what is entered, even if nothing is entered.

                   

                  I want to enter a columun of numbers going from record to record in the same field in list viewMuch like a spread sheet.

                  • 6. Re: Next Record script not working.
                    Stephen Huston

                    One might expect an onExit from the field would work as a trigger. However, onExit is one of those triggers which executes the script before the exit-field is allowed to complete. This means you can test within the script and then exit the script with a true (1) or false (0) script result. That result determines if you get to exit the field or not.

                     

                    That may mean that whatever you are trying to accomplish within the script is actually being attempted while you are still in the field, which would explain the delays  and misdirection from using that trigger.

                     

                    Look over the details of script triggers in the built-in FileMaker Help files at:

                    Home > Designing and creating databases > Creating and managing layouts and reports > Setting up script triggers

                     

                    Maybe OnExit:

                         Go to next record

                         ExitScript (result=1)

                     

                    and an OnRecordLoad trigger = Go To Field (your field here)

                    • 7. Re: Next Record script not working.
                      DavidJondreau

                      You've got an OnObjectExit trigger on a field.

                       

                      When you attempt to exit that field, it triggers the script, that script goes to the next record...which triggers the script, putting you in a loop.

                       

                      The easy solution? At the end of the script, put in an Exit Script[False] script step.

                       

                      Message was edited by: DavidJondreau

                      • 8. Re: Next Record script not working.
                        SteveNoble

                        FYI I have entered the date and run my reports the hard way, so this is not urgent at this point.

                         

                        I am still trying to wrap my head around why something so "simple" did not work. Davids last post makes sense, at least visually is looks like a loop.

                         

                        Stephen last suggestion did work but only after I removed all tab controls on the layout.

                         

                        This maybe the behavior of these triggers, if so that answers my question.

                         

                        Thanks for everyones help.