I wan't to create a ContentDocumentLink
and delete him in an other function, i tried this code:
// function of creation:
ContentDocumentLink cdl = new ContentDocumentLink(
ContentDocumentId = doc.Id,
LinkedEntityId = ws.Id
);
insert cdl;
// function of deletation
delete cdl;
But when I run this function of creation and after function of deletation, I have this error:
Delete failed. First exception on row 0 with id 06A0E000002ea8HUAQ; first error: DEPENDENCY_EXISTS, Cannot complete this operation.
// this part is translate by me:
You can't delete this document of is own library
I found this answer, but I didn't understood how he made to delete the ContentDocumentLink
.