//Create Document ContentVersion cv = new ContentVersion (); cv.Title = ‘Test Document‘; cv.PathOnClient = ‘TestDocument.pdf’; cv.VersionData = Blob.valueOf (‘Test Content‘); cv.IsMajorVersion = true; Insert cv;
Table of Contents
How to write test class for trigger in Salesforce?
Vamshi-Writing test class for your trigger is straight forward approach, all you need to do is create a new Account record in your test class, then automatically it will cover code coverage for that trigger code. Note: Your trigger code is not bulikfied, you should not use DML statement inside the for loop.
What is content document link in Salesforce?
One Content Document can have multiple content versions. Content Document Link:- Represents the link between a Salesforce CRM Content document or Salesforce file and where it’s shared. A file can be shared with other users, groups, records, and Salesforce CRM Content libraries. Here is the code for the test class.
How to attach content version to ContentLink from contentDocument?
Rather than querying ContentDocumentId from ContentVersion, query that from ContentDocument and use that as contentlink.ContentDocumentId=documents [0].Id; Show activity on this post. Try setting the FirstPublishLocationId to the specified location you want to attach the Content Version first.
What are the errors for contentdocumentlink trigger?
Below is the test class that I have written for contentdocumentlink trigger. And its failing to insert the cdl due to insufficent access. Error:System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, You do not have the level of access necessary to perform the operation you requested.