4 Replies Latest reply on Dec 22, 2016 5:37 PM by danjamins

    Hide Records From Layout


      Hi Everyone!


      I have a question that I've half figured out but maybe there's a better way to do it.


      What I'm trying to accomplish is hiding records on a specific layout from being displayed if a field is set to a certain value.


      Table: Accounts

      Field: Deleted (boolean values 1 or 0 stored)

      Layout: Accounts_DETAIL



      I want to allow users to "delete" Accounts without actually deleting the record so we can restore the Account if it was deleted accidentally. Right now I setup a script that when the user clicks "Delete Account" it sets the field "Deleted" to 1. Then anytime the user goes into the layout, I have a script trigger on the layout to omit all records with that field set to "1" but the only problem is if they do a "Show All" command it will display these records again.


      Is there a way I can prevent them from ever viewing these records again unless the Delete field is set to 0 or empty?

        • 1. Re: Hide Records From Layout

          I encourage you to avoid using User Interface for security.  It can be in addition, but not in place of.  You should go to permissions for that privilege set and use the boolean test to control access to the records for that table or even access to that layout. 


          But you can go to Inspector and to the Data tab and go down to the Hide and put the boolean in there to hide objects/fields/etc. 

          • 2. Re: Hide Records From Layout

            Use OnLayoutEnter to perform a script that either performs a find for records that are not deleted or that constrains the found set so that they are not deleted.


            Set up the OnModeChange trigger to constrain the current found set to undeleted records when ever the window mode changes to Browse mode


            Enter find mode [ ]

            Set field [YourTable::Deleted ; 1 ]

            Omit Record

            Constrain Found Set [ ]

            With this second script, any find performed by the user or by a script on this layout will automatically be constrained to omit "deleted" records.


            Set up custom menus that either remove the Show All and Show Omitted options or that replace them with scripts that also omit "deleted" records.


            An alternative approach to the first two scripts is to set up record access control in manage security to keep non full access users from viewing "deleted" records. "no access" records are automatically omitted from scripts performed by the user both manually and via a script so that would leave only the need for a custom menu to complete this process.

            • 3. Re: Hide Records From Layout

              Thank you, this is exactly what I was trying to do!

              • 4. Re: Hide Records From Layout

                Thank you Taylor. It's not really for security purposes. It's mostly because users want to delete records if they accidentally duplicate an Account and use a slightly different Account Name.


                No reason for them not to see these records or have access to them besides just having them not show up in their searches. If they ever want to pull these records up intentionally or if they accidentally "delete" the wrong account it can be restored easily.


                Another option I'm thinking about is having a server-side script that exports the accounts marked for delete into an archive folder on the server then removes the account and related records from the live system. This way I can restore from an archive if a user accidentally removes the wrong account.