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
Jeannine RobitailleJeannine Robitaille 

Can't Add 1 file to Opportunity

I have a trigger on ContentDocumentLink for Before Insert. The trigger handles the condition to prevent an insert and has a error that displays. In debugging, the trigger appears to function as expected except a different error displays - "Can't Add 1 file to Opportunity". See attached error displayed instead. Yet I am expecting the error from my trigger to show "File Upload is restricted for Opportunity".
Tapas Chakraborty 10Tapas Chakraborty 10
hey Jeannine, 
check this doc: https://help.salesforce.com/s/articleView?id=000381870&type=1. 
Short answer:,
1. deactivate your trigger and check if the error persists.
2. check if you've exceeded file storage limits. 
3. check if any fields are marked as required on ContentVersion object.
4. check if there are any other validation rules written on ContentDocumentLink object.
Jeannine RobitailleJeannine Robitaille
The article is exactly the behavior I am getting.  I did find another ContentDocumentLink Trigger coming from a managed package.  I am inquiring with the vendor to better understand what the trigger actually does.