How to lock a Record

There are three ways to lock a record in Salesforce

1) Trigger
2) Record Types
3) Validation Rules

This is the first option the would crawl in to peoples mind whenever there is record locking involved is Trigger. This might be an option to lock a record but writing lot of triggers might bring us close to governor limits. Hence, this would be the last option for me.

Record Types
Lets assume that the record has a check box call ‘Restrict’. Create a Read Only record and create a workflow rules that changes the record type to ‘Read Only’ if the ‘Restrict’ check box is checked.

Validation Rules
Write a validation rules saying (account.Restrict__c, true), then display an error message saying “Record is read only”

Record Types is the cleanest way I could think of to lock a record in Salesforce.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s