4 Replies Latest reply on Mar 17, 2010 8:48 AM by Radcon

    Trapping for unfriendly messages



      Trapping for unfriendly messages



      I have implemented record level access to lock records so that unwanted changes are minimized.  Works fine, but when a user tries to modify a field, they are presented with "Your access privileges do not allow you to perform this action".   I have tried using the Get(LastError) function in a custom dialog box on several OnObject triggers, but have not been able to catch the error

      (Set Error Capture(ON)).  How can I replace the unfriendly message with a simple "Record is locked" message?



        • 1. Re: Trapping for unfriendly messages

          Try this script applied to the fields in question as an OnObjectKeystroke trigger:


          If [ Let ([ key = Code ( Get ( TriggerKeystroke ) ) ]; key = 9 or key = 10 or key = 28 or key = 29 or key = 30 or key = 31 )]

            #do nothing

          Else If [ Get ( AccountPrivilegeSetName ) = "user" ]

            Show Custom Dialog [ Title: "Error"; Message: "Field is locked"; Buttons: “OK” ]

            Exit Script [ Result: 0 ]

          End If


          The If allows keystrokes such as tab, enter and arrow keys in the field.

          The Else If traps for a specific privilege set, shows a custom error dialog and exits with 0 (false). This exit cancels the keystroke so the RLA error never appears.

          • 2. Re: Trapping for unfriendly messages

            Thanks for your quick reply!

            The script certainly traps the error message, but now I can't unlock the field.  I have a little lock icon that I click on to toggle the lock status of the record, and when I unlock the record, I still get the scripted dialog box that says the record is locked even though it isn't.  I suppose this script should check for the lock status flag before doing anything else? Also, will I have to apply this script trigger to all fields on the layout, or can I use a OnLayout script trigger?

            • 3. Re: Trapping for unfriendly messages

              Aha, so this is what happens when you don't provide enough information about what you have set up and how! :)


              I could guess at what you will need to do but without knowing how you have set it up so far, it would be a great deal of guessing. For example, what does the lock do - toggle a field between 1 and 0? What is the RLA test you have applied? What privilege sets are affected? etc...



              • 4. Re: Trapping for unfriendly messages

                Don't be sorry, you helped me tremendously!


                Here's the script that works: 

                   If [ Let (

                      key = Code ( Get ( TriggerKeystroke ) ) ;

                      key=9 or key=10 or key=28 or key=29 or key=30 or key=31

                      ) ]

                     #do nothing; certain keystrokes are allowed

                  Else If [ RME Items::Lock = 0 ]

                     Show Custom Dialog [ Title: "Record is locked"; Message: "Click on the lock below to make changes"; Buttons: “OK” ]

                     Exit Script [ Result: 0 ]

                  End If


                On fields with drop down menus, I had to use the OnObjectEnter trigger.  The field briefly flashes before the dialog message appears and is slightly annoying, but it does work.  The script used in a regular edit field with a OnObjectKeystroke works beautifully.  Thanks again!!