Search This Blog

Wednesday 25 July 2012

Lock a Record in Salesforce

There are three ways to lock a record in Salesforce
1) Trigger
2) Record Types
3) Validation Rules
Trigger
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.yourfield__c, true), then display an error message saying “Record is read only”

No comments: