You need to sign in to do that
Don't have an account?

Assistance writing a test class for ContentDocumentLink
Hi All
I have used the help on this board to create to apex triggers which impact the ContentDocumentLink and ContentDocument object. These triggers work great in the sandbox. When i go to deploy these triggers into production i get an error saying that i dont have the right code coverage.
I believe the way to fix this is to write a test class, i have tried to do this with little success. Is there a way i can get around the need for code coverage? Is there an easy way that someone with very rudimentary understanding of apex and write a trigger?
The triggers are:
I have used the help on this board to create to apex triggers which impact the ContentDocumentLink and ContentDocument object. These triggers work great in the sandbox. When i go to deploy these triggers into production i get an error saying that i dont have the right code coverage.
I believe the way to fix this is to write a test class, i have tried to do this with little success. Is there a way i can get around the need for code coverage? Is there an easy way that someone with very rudimentary understanding of apex and write a trigger?
The triggers are:
trigger ContentDocumentLinkTrigger2 on ContentDocumentLink (before delete) { for (ContentDocumentLink cdl : Trigger.old) { if([SELECT PermissionsModifyAllData FROM Profile WHERE Id = :UserInfo.getProfileId()].PermissionsModifyAllData) { return; } cdl.addError('Document links cannot be removed'); } }and
trigger ContentDocumentTrigger2 on ContentDocument (before delete) { for(ContentDocument cd : Trigger.old){ if([SELECT PermissionsModifyAllData FROM Profile WHERE Id = :UserInfo.getProfileId()].PermissionsModifyAllData) { return; } cd.adderror('Attached files cannot be deleted.'); } }