Need to lock a records from being edited? Let’s review how it can be done

 From time to time, situations will come up where you will want to lock down records to prevent them from any future edits.  In this post we will look at some different ways to lock-down records, to prevent users from modifying.  Some examples might be a Closed-Won or Closed-Lost Opportunity record, that you want to preserve once the records life has come to an end.  Or perhaps you have a closed Case record, that you don’t want users going back and editing or deleting to preserve the data that was captured at that moment in time.  Another example might be a record that is being pulled into a separate database, and you want to ensure that data doesn’t change.  Whatever the use case is, our team can deliver those solutions.

Lock1.png

Let’s review a few of the options available:

·      Record Types & Page Layouts

o   The most straightforward solution would be to implement a separate record type named “Locked” or “Read-Only”.  Along with that record type, you can assign a read-only page layout assigned to that record type.  Once those are in place, workflow rules can be built to change the record to the Read-Only record type, once it meets that locked criteria you set for your Org.  However, this is not an option if you are using record types for some other purpose and do not want to change it just to meet this requirement. Also, note that using this to lock records is not a fool-proof solution as users will still be able to edit the record from the list view.

·      Record Ownership changes

o   Changing the record owner is another potential solution.  Using another workflow or trigger, you can change the owner so that other users are unable to edit.  This solution will be dependent on what your Organization Wide Default settings are, which have in place sharing settings that don’t allow edits.

·      Triggers

o   Writing a trigger to lock a record is another option, however this requires custom development.  Furthermore, it will only stop an edit once a user tries to save – which may not provide the best user experience.

·      Validation Rules

o   Acts very similarly as the trigger will, by flagging the record from being edited once the system recognizes an attempt to change it.  Also like the trigger, it only stops the user when attempting to save.

·      Visualforce Pages

o   Custom Visualforce pages can be created & used to hide the Edit and Delete buttons

Lock2.png

Like so many requirements your Org may have, Salesforce provides several different paths to achieving it.  When locking records, you’ll need to find the best solution that fits your specific Org and how you utilize it.  Most of the time you don’t want to hide records from users, but prevent an inadvertent or intentional edit – which is can certainly be achieved.