4 Replies Latest reply on May 15, 2014 2:09 PM by philmodjunk

    Behavior of OnRecordLoad script trigger


      Behavior of OnRecordLoad script trigger


           What I'm trying to do is setting up a global variable that shows the current record number. What I thought would work is writing a script like this:

           Set Variable [$$R; Value:Get (RecordNumber)]

           and attach it to a OnRecordLoad script trigger.

           Since OnRecordLoad is a post-event script trigger, it should be triggered after the new record I switch to has become my current record. So I thought the global variable '$$R' will always show the current record number. However, instead of getting the current record number,  I got the record number of the record that I switched from, which is the last record that I was looking at.

           Could anyone please tell me why is this happening? and how to fix it? 

           Thank you

        • 1. Re: Behavior of OnRecordLoad script trigger

               How are you monitoring the value of this global variable? I would guess that you put <<$$R>> as layout text onto your layout in order to set up a merge variable.

               If so, you need to refresh this layout object after changing the value of the variable.

               In FileMaker 13, you can give this text object and object name and add Refresh Object as the last step of your script.

               In older versions, you'd use Refresh Window.

          • 2. Re: Behavior of OnRecordLoad script trigger

                 Oh yes, and if all you want to do is display the current record number, this can be done without scripting and without using any variable. There is an option for adding a layout symbol for this available from your Insert Menu if you make this selection while in Layout Mode.

            • 3. Re: Behavior of OnRecordLoad script trigger

                   Thanks for replying PhilModJuk! I did forget about the refresh window part. Eventually I want to havesomething like this:

                   <<RecordNumber>> out of <<FoundCount>> (<<TotalRecordCount>> Total)


                   4 out of 35 (200 Total)

                   To achieve this, the current solution is using three unstored calculation fields for those three items, which in my opinion may not be a good way to implement something like this. I think I could use global variables to get the same result. You're right about the record number part. I could simply use "@@" to get the current record number. What about the other two values? Do I have to use scripts and triggers?

              • 4. Re: Behavior of OnRecordLoad script trigger

                     Check your Insert Menu. There should .FP7 compatible symbols for each. (FileMaker 12 introduces new symbols for these type layout objects that are more descriptive than @@)