1

I am trying to lock the Attachments related to a custom object using the below 2 lines of code, when the custom record is under approval process. But I am getting an error as:

"System.UnexpectedException: Entity id: 00P4D000001QYbT cannot be locked"

Can anyone tell me why this is failing and is there a way to fix this?

Code Used

List<Attachment> atch2Lock = [SELECT Id from Attachment WHERE ParentId = 'aBn4XX000000UI']; 
Approval.LockResult[] lrList = Approval.lock(atch2Lock, false);

Your Answer

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

Browse other questions tagged or ask your own question.