13 Replies Latest reply on May 31, 2017 11:00 PM by Fred(CH)

    OnModeExit trigger in find mode

    FabriceNordmann

      Hi,

      We've already had this layout trigger for a while, but I've never used it in Find Mode because I've never understood what it could be used for. My expectation was that the trigger would be performed before the find, and that would help adding criteria to the user-defined search.

      Currently, the sequence when a find is performed is really strange - and IMHO absolutely useless:

       

      - search criteria are validated and throw an error (prompt) if invalid, so the triggered script has no chance to fix

      - the triggered script is performed

      - the find is performed WITH the criteria as they were before the triggered script is performed

       

       

      Here is a sample file that illustrates the issue.

       

      Cheers,

      Fabrice

        • 1. Re: OnModeExit trigger in find mode
          TSGal

          1-more-thing:

           

          Thank you for your post.

           

          The OnModeExit script trigger does execute before the event has been processed.

           

          Looking at your file, I'm not sure what you are trying to convey.  If I type in "something" into the field and press "Perform Find", the OnModeExit script trigger is executed and displays the found count as 1 for the number of find requests.  After clicking OK, the Find is executed and the OnModeEnter then displays the record found count of 3.

           

          TSGal

          FileMaker, Inc.

          • 2. Re: OnModeExit trigger in find mode
            FabriceNordmann

            While the dialog is displayed, you can see that the triggered script already modified the criteria. (to "="), so it should return the empty records.

             

             

            But it returns the ones with "something"

            • 3. Re: OnModeExit trigger in find mode
              TSGal

              1-more-thing:

               

              The Find criteria is already stored and ready to be processed prior to OnModeExit trigger.  The OnModeExit trigger gets fired as you are changing modes, so you cannot modify the existing find criteria.  If you want to add more criteria, then have the "Perform Find" button execute a script that adds the additional find criteria before Perform Find [ ].

               

              TSGal

              FileMaker, Inc.

              • 4. Re: OnModeExit trigger in find mode
                FabriceNordmann

                We're saying the same thing, but I think it's an issue, and that there is no time frame between the perform find and the mode change, which you can see with the found count. Perform find implies go to browse mode, the event IS the perform find. If the trigger was really a PRE, the script would run before the find is performed.

                Let me rephrase and describe precisely the sequence.

                 

                1 - EVENT : perform find button (or enter key, or perform find script step). This action is the event because that is what is cancelled by a false result.

                2 - The find criteria are saved and validated

                3 - The triggered script runs (and in this instance modifies the find criteria). We're still in find mode.

                4 - The find is performed with the criteria saved in 2.

                 

                What the sequence should be :

                1-

                3-

                2-

                4-

                 

                Otherwise, I really have no clue what this trigger can be used for.

                • 5. Re: OnModeExit trigger in find mode
                  TSGal

                  1-more-thing:

                   

                  Perform Find [ ] executes the Find criteria.  FileMaker then attempts to display the information in Browse Mode.  Since you are switching modes, the OnModeExit script is triggered.  Since the Find criteria is already stored and processed, any attempt to add to the Find criteria is only possible before executing Perform Find.

                   

                  You said:

                  > I really have no clue what this trigger can be used for.

                   

                  One example is tracking user actions to see who visited Layout Mode and Browse Mode.  You may execute an OnModeExit trigger that logs Get (UserName), Get (CurrentTimestamp), Get (LayoutName), etc.  If you later notice a change in a specific layout, you can search the log file to see who visited that layout.

                   

                  TSGal

                  FileMaker, Inc.

                  • 6. Re: OnModeExit trigger in find mode
                    FabriceNordmann

                    Are you writing to a log in Find mode?

                    I'm not saying the trigger is useless in browse mode but in find mode.

                    • 7. Re: OnModeExit trigger in find mode
                      TSGal

                      1-more-thing:

                       

                      You asked

                      > Are you writing to a log in Find mode?

                       

                      No.  In the OnModeExit script, I switch to Browse Mode.  Using your file and my example, I created a new table named "LOG" with three fields:

                        Timestamp (Timestamp)

                        UserName (Text)

                        LayoutName (Text)

                       

                      The accompanying layout is also named "LOG".

                       

                      I added the following script steps to the end of the "OnModeExit" script:

                        Freeze Window

                        Set Variable [ $layout ; Value: Get (LayoutName) ]

                        Go to Layout [ "LOG" (LOG) ]

                        Enter Browse Mode [ Pause: Off ]

                        New Record/Request

                        Set Field [ LOG::Timestamp ; Get (CurrentTimestamp) ]

                        Set Field [ LOG::UserName ; Get (UserName) ]

                        Set Field [ LOG::LayoutName ; $layout ]

                        Commit Records/Requests [ With dialog: Off ]

                        Go to Layout [ original layout ]

                       

                      This will write the information to the LOG table before presenting the Find results.

                       

                      TSGal

                      FileMaker, Inc.

                      • 8. Re: OnModeExit trigger in find mode
                        FabriceNordmann

                        Ok. I'd do this on mode enter then. So I cou also log the found count.

                        Thanks for your replies. Still not convinced.

                        • 9. Re: OnModeExit trigger in find mode
                          AndrewD

                          I use this script trigger to intervene in user finds, but you MUST do the Perform Find[] script step on your own within the script trigger.

                           

                          Do note I've only used the OnModeExit trigger for this purpose (not logging as in the example above) so I don't know how it might interfere with other uses of the trigger, I just know I get the correct find results displayed in this specific instance.

                           

                          Edit: It would be nice to have a "BeforeFind" trigger...

                          1 of 1 people found this helpful
                          • 10. Re: OnModeExit trigger in find mode
                            FabriceNordmann

                            I don't understand how you did.

                            The only thing I can imagine is:

                            -modify last find

                            -do stuff to modify the criteria

                            -perform find

                             

                            but it means 2 finds and it does work if the trigger event was a Constrain or Extend found set.

                            • 11. Re: OnModeExit trigger in find mode
                              AndrewD

                              Just drop a Perform Find[] in there. From your example file on the first post, here is the modified onModeExit script:

                               

                              If [Get ( WindowMode ) = 1]

                              Set Field [TEST Trigger::test; "="]

                              Perform Find[]

                              End If

                               

                              I don't think it will work for a constrain/extend find since you can't capture what type of find it is.

                              • 12. Re: OnModeExit trigger in find mode
                                FabriceNordmann

                                That is already very interesting! thank you!

                                • 13. Re: OnModeExit trigger in find mode
                                  Fred(CH)

                                  Another way is to use Custom Menus, where Perform Find, Constrain and Extend Found Set are real scripts and using the activation of according standard commands. So it is easy to add criteria before the 3 "perform steps".

                                   

                                  AndrewD a écrit:

                                  […]

                                  I don't think it will work for a constrain/extend find since you can't capture what type of find it is.