0

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

2
  • Can you check the results? 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. – sfdcfox May 2 at 22:56
  • Figured out the issue. The issue was that the user was having 'Modify All' on the object. After removing that, it worked. – Avinash Kumar May 3 at 1:53
0

Figured out the issue. The issue was that the user was having 'Modify All' on the object. After removing that, it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.