15

Content Document: It Represents a document that has been uploaded to a library in Salesforce CRM Content or Salesforce Files. The maximum number of documents that can be published is 30,000,000. This object record you don’t have to create. It gets created when you create ContentVersion which is the child of ContentDocument. Content Version: Represents a ...


14

You need the LinkedEntityId on the ContentDocumentLink


11

Looks like there are some changes recently. I am seeing below pattern with API version 48 For authenticated users /sfc/servlet.shepherd/document/download/06955000001UrOPAA0 For communities /sfsites/c/sfc/servlet.shepherd/document/download/06955000001UrOPAA0 ID in the URL being content document ID.


11

You can do it in one query if you start from the Custom Object and utilize the ContentDocumentLinks relationship in a subquery. Here's an example with Account as the main object: SELECT Name, (SELECT ContentDocumentId, ContentDocument.Title, ContentDocument.ContentSize FROM ContentDocumentLinks) FROM Account Note that the relationship is ...


11

It's determined by the PathOnClient field as populated when you create the ContentVersion. As an example, in one of my orgs I uploaded a file called App.logo.png through the API, populating its file name in the PathOnClient field and App.logo in the Title field. The system inferred png as the value for FileExtension.


10

You can directly download using the ContentVersion Id: /sfc/servlet.shepherd/version/download/<CONTENT VERSION ID starting with 068> The ContentVersion is related to the ContentDocument via a dedicated ContentDocumentId. Get the ID of the one where IsLatest is true.


10

Yes, the documents seem to be out of date? There can be multiple entries for each ContentDocument. In the case of attachments (Lightning uses ContentDocument for attachments), there will be a record in the ContentDocumentLink for both the UserId and the record that is the Attachments Parent. You can use a query similar to the below to find details of the ...


10

You can also download multiple files as a zip {!URLFOR('/sfc/servlet.shepherd/version/download/' & delimitedSelectedIdList &'?')} example: {!URLFOR('/sfc/servlet.shepherd/version/download/068xxxxxxxxxxxxxxx/068yyyyyyyyyyyyyyy?')} more details on my blog


9

This was actually solved by setting the pdf filetype to 'Execute in Browser' from Setup -> Security Controls -> File Upload and Download Security


8

Add this line: newContentVersion.firstPublishLocationId= user.Id; A more detailed explanation: When documents are created via apex (contentversion object), you need to specify the library otherwise they will always be created in private library of the context user. Since you are querying a random user (and probably this user is not the context user of ...


7

You are correct. You will have to rely on existing metadata to complete your tests. You can still create documents and put them existing library's. One thing I did in my tests for a similar implementation is to ensure that after every SQL I check to see if the list was empty. If it was I set a variable to a useful error message. Then I system.assertEquals('...


7

The ContentVersion and ContentDocument objects don't store MIME types. They do, however, store a FileType, which contains strings like "WORD_X", "PDF", and "POWER_POINT_X", which you could potentially map to MIME types. ("UNKNOWN" is also one value for this field). Additionally, the original file's FileExtension is stored on these objects and could be ...


7

OK, I got this to work. The key to getting the FileType set correctly and thus a preview generated is to ensure that the proper file extension is set via ContentVersion.PathOnClient. Additionally, while it may be necessary in your final web service, the base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8') creates a bad version of the file data when ...


6

Your URI is invalid according to RFC 3986: the fragment part (the "#search") should come after the query part (the "?searchTerm..."). If you fix that, the PageReference will correctly parse the query terms rather than throwing them away. Its a pity PageReference silently discards the query terms rather than throwing an exception. (You can ...


6

In query editor, you will get this. But if you do it in apex , you will actually get the blob data.Try the same query in execute anonymous


6

Just create an instance of ContentDistribution by providing you ContentVersion and a Name and then query the DistributionPublicUrl. ContentDistribution cdl = new ContentDistribution(); cdl.ContentVersionId = '0680DXXX002RmxQAE'; cdl.Name = 'PublicShare'; insert cdl; cdl = [SELECT DistributionPublicUrl FROM ContentDistribution WHERE Id = :cdl.Id LIMIT 1]; ...


6

You can utilize workbench to view the details of the field. It's a picklist field with the values as below. label: Visible to Anyone With Record Access value: N label: Private on Records value: P


5

Edit Your trigger definitely needs to fire on ContentVersion. I've quoted the relevant portions of the Object Reference below, having italicized two very important points under the ContentDocument section. You'll see that the Object Reference clearly states that the ContentVersion object is what should be used to both create and update ContentDocuments. As ...


5

We needed these content to be exported urgently. So, couldn't tried any AppExchange App. Every salesforce content has it's download URL like : http://Your_ORG_URL/sfc/servlet.shepherd/version/download/?asPdf=false" We logged into one browser and wrote a automation script to download these files by it's URL. It was quite fast.


5

You will need to set the Mime Content-Type of the attachment to match that of the ContentVersion. This will tell your browser/mail client how to open the attachment. The Mime Type for the ContentVersion is in FileType. You can set the Mime Type on the EmailFileAttachment using setContentType(). efa = new Messaging.EmailFileAttachment(); efa.setFileName(cv....


5

You should add location for the file (the library), I use ContentLocation for creating my ContentVersion: ContentVersion cv = new ContentVersion(); cv.ContentLocation = 'S'; // S = within Salesforce, E = External cv.VersionData = body; cv.Title = fileName; cv.PathOnClient = filename; insert cv;


5

For ContentVersion, the property that contains the blob data is 'VersionData'. Line 6 should be changed to: controller.file.VersionData = Blob.valueOf('populated'); See more here: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentversion.htm


5

FileType isn't writeable, but PathOnClient is - it's createable, but not updateable. The system will infer the type of file from the pathname extension you supply in that field. (ContentNote records will have type SNOTE; they don't have extensions). See the SOAP Reference: FileType is defined by either ContentUrl for links or PathOnClient for documents, ...


5

Your Apex method could return the ContentDocumentId instead, then you can benefit from the filepreview named page to have the document preview, like this: viewPdf() { this[NavigationMixin.Navigate]({ type: 'standard__namedPage', attributes: { pageName: 'filePreview' }, state : { recordIds: '...


5

Aside from plain text files (e.g. source code or README.TXT type files), most files follow an internal structure. This means that two similar files (e.g. two GIF or DOCX) being "added together" would result in an invalid file structure. Let me give you an example using plain text; we'll choose XML. File A <?xml version="1.0" encoding=&...


4

Retrieving documents from a library using filter like [SELECT Title FROM ContentVersion WHERE ContentDocument.ParentId = :workspaceId] may be incorrect, if document is shared with several libraries, and workspaceId is not equal to the library it was initially uploaded to. Example: Doc1 was uploaded in Library1, and then shared with Libary2. If you use ...


4

ContentVersion can not be the parent of any custom object. ContentVersion can be the child, via a lookup relationship to Custom or Standard objects. This is done by Setup | Customize | Salesforce CRM Content | Fields | New Historically, ContentVersion and its related objects ContentWorkspace, ContentDocument etc. were acquired through an acquisition and ...


4

I was able to work around this by inserting new ContentVersion with the following: OWNERID: 005o0000002DMoTXXW (my id, or believe you can omit) TITLE: title of file PATHONCLIENT: C:\sfdc-migration\old org\attachments\myfile.pdf VERSIONDATA: C:\sfdc-migration\old org\attachments\myfile.pdf DESCRIPTION: description of file ORIGIN: H Then do a subsequent ...


4

public ID setupContent(){ RecordType ContentRT = [select Id FROM RecordType WHERE Name='Sales Documents']; ContentVersion testContentInsert =newContentVersion(); testContentInsert.ContentURL='<a target="_blank" href="http://www.google.com/';" rel="nofollow">http://www.google.com/';</a> testContentInsert.Title ='Google.com'; ...


4

From Base Lightning Components Considerations: When working with type="file", you must provide your own server-side logic for uploading files to Salesforce. [...] Uploading files using this component is subject to regular Apex controller limits, which is 1 MB. To accommodate file size increase due to base64 encoding, we recommend that you set the ...


Only top voted, non community-wiki answers of a minimum length are eligible