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?
List<Attachment> atch2Lock = [SELECT Id from Attachment WHERE ParentId = 'aBn4XX000000UI']; Approval.LockResult lrList = Approval.lock(atch2Lock, false);