5 Replies Latest reply on Apr 16, 2009 4:17 PM by davidhead

    Trapping or changing a particular error or warning message

    ralvy

      Title

      Trapping or changing a particular error or warning message

      Post

      I'd love to know if there's a way to get rid of this warning:

       

      Before typing, press Tab or click in a field, or choose the New Record command.

       

      I don't see a place where I can either reconfigure that message or get rid of it altogether.

        • 1. Re: Trapping or changing a particular error or warning message
          Orlando
            

          Hi ralvy,

           

          If you are using FileMaker Pro 10 you could use an OnLayoutKeystroke script trigger to test if the user is in a field when they hit a key on the keyboard, and if not display your own custom message, and take them to a field.

           

          I have just written this script and it seems to do the trick:

           

          # 
          If [ IsEmpty ( Get ( ActiveFieldName ) ) ] 
          Show Custom Dialog [ Title: "Message"; Message: "Your message here."; Buttons: “OK” ] 
          Go to Field [ TABLE::FirstField ] 
          Halt Script 
          End If
          # 

           

          In testing this I notice to suppress the default message you need to have the Go to Field step in there before the end, and to stop the field being updated with the users keystroke you need to halt the script. 

           

          So then all you need to do after writing this script is to assign it to the layout by going into layout mode and selecting 'Layouts > Layout Setup...' and then under the 'Script Triggers' selecting OnLayoutKeystroke and choosing your new script when the dialog pops up.

           

          Also if you want it to ignore keystrokes like arrow keys, escape and delete etc, change the If calculation to the following and they will be ignored

           

          IsEmpty ( Get ( ActiveFieldName ) ) and not Length ( FilterValues (  "8¶9¶10¶13¶27¶28¶29¶30¶31¶32¶127"  ; Code ( Get ( TriggerKeystroke ) ) ) ) 

           

          And job done. 

           

          I hope this helps 

          • 2. Re: Trapping or changing a particular error or warning message
            davidhead
              

            Hi Orlando

            You don't actually need your Go to Field and Halt Script steps - all you need is Exit Script [Result: 0].

            That will 'eat' the keystroke for you since the trigger is pre-event. 

             

            Also I don't think you need the Length function in your second If calculation. This will do the job:

             

               IsEmpty ( Get ( ActiveFieldName ) )

               and

               not FilterValues (  "8¶9¶10¶13¶27¶28¶29¶30¶31¶32¶127"  ; Code ( Get ( TriggerKeystroke ) ) )

            • 3. Re: Trapping or changing a particular error or warning message
              Orlando
                 Thanks David, I did not know that about the Exit [Result ; 0], works much nicer now.
              • 4. Re: Trapping or changing a particular error or warning message
                ralvy
                   Thanks, Orlando and David. This is exactly what I was looking for.
                • 5. Re: Trapping or changing a particular error or warning message
                  davidhead
                    

                  No problems.

                  In our new FileMaker Training Series courses, I spend some time looking at the implications of pre- and post-trigger events and how you can control them. Exiting the script with a false result is a big part of that. So getting to know which triggers are pre-event is helpful. Also useful for the Developer Certification exam. ;)