My requirement is to make a record read only when value of a field changes to 'Inactive'.
I read that records can be locked using approval.lock in Apex.
Hence, I was trying to use Approval.lock record apex to lock the record. The record is getting locked but it's still editable. The profile is not Sys Admin and it does not have Modify All Data permission.
Also, the object doesn't have any approval process. I'm just locking the record using Apex.
Any ideas why the record is still editable ?
Avinash
Approval.LockResult result = Approval.lock(recordId); System.debug(result.isSuccess()); System.debug(result.getErrors());
See what you get in the debug logs. We can help you from there.