function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Giovanni Di SantoGiovanni Di Santo 

Test trigger on ContentDocumentLink

I developed a trigger firing after inserting records in the ContentDocumentLink object.
You can find the code here: http://nopaste.linux-dev.org/?780808.

The trigger works just fine but I have a problem with the testing class I wrote for it: http://nopaste.linux-dev.org/?780809

As you can see there is an insert for the object checked by the trigger.
When I run the test class I don't receive any error but the coverage is stuck at 0% no matter what I try to do. It seems like the trigger is not fired at all.

I suppose I'm making a mistake somewhere but I don't know where...

Can you guys guve me any hint?

Thanks,
Giovanni
SonamSonam (Salesforce Developers) 
Are you still facing this issue? Can you share the code of test class as I am not able to access it on the link you've provided.
Giovanni Di SantoGiovanni Di Santo

Hi Sonam,
It turned out the problem was releated to the test class api version, I siwtched to version 35.0 and the test class worked.

Let me know if you still need the code.

Giovanni

Nitin Paliwal 9Nitin Paliwal 9
Hey Glovanni,
Can you share the code you wrote to cover the contentDocumentLink trigger.
I am in urgent need for it?
 
Giovanni Di SantoGiovanni Di Santo

Hi Nitin,
Can you give me your email address? I'm going to share you my code in private.

I solved the problem by switching to the newest api version though, even if we had a strange problem while we had to deploy the class in production. We had to deploy that class separately...

Nitin Paliwal 9Nitin Paliwal 9
Hey Giovanni, Thanks. I also resolved the issue. THanks
Keval Suchak 4Keval Suchak 4
Hi Glovanni,

I've posted one issue related to trigger I've written on ContenDocumentLink : https://salesforce.stackexchange.com/questions/197003/how-to-show-error-msg-in-contentnote
would you pls share ur view on this or can u pls share ur code which u have written so I can get some idea.
Giovanni Di SantoGiovanni Di Santo
Hi Keval, Unfortunately I have no longer access to the test case I wrote. I'm afraid I can't help you, sorry.