You need to sign in to do that
Don't have an account?
Apex developer 21
How do i write a Unitest for Contentdocument
trigger NoteOnContentDocument on ContentDocument (before delete) { for (ContentDocument c : Trigger.old){ List<ContentDocumentLink> links = [ SELECT LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId= :c.Id ]; if (Approval.isLocked(links.get(1).LinkedEntityId)){ c.addError('Approval pending. You do not have the permission to delete this note, Please contact your administrator.'); } } }
All Answers
Try this
09:33:50:461 EXCEPTION_THROWN [13]|System.DmlException: Delete failed. First exception on row 0 with id 0693E0000000TCqQAM; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NoteOnContentDocument: execution of BeforeDelete
09:33:50:000 EXCEPTION_THROWN caused by: System.ListException: List index out of bounds: 1