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
    Commented May 2, 2021 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. Commented May 3, 2021 at 1:53

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .