Skip to main content
54 votes
Accepted

Obtaining all ContentDocument records using SOQL

Just found out today that with the Spring 19' update there is a new setting in the "Setup -> Permission Sets -> (choose an existing or create a new one) -> App Permission -> Content -> Query All Files:...
Denis S.'s user avatar
  • 686
22 votes
Accepted

Triggers on ContentObjects

Alright, I spent a couple of days going through it all, and the short answer is: it's complicated. Depending on what you want your triggers to do, you may need to have different triggers on different ...
AvailableName's user avatar
18 votes

Content Document download URL params

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 /...
Victor's user avatar
  • 3,611
17 votes

Content Document download URL params

You can also download multiple files as a zip {!URLFOR('/sfc/servlet.shepherd/version/download/' & delimitedSelectedIdList &'?')} example: {!URLFOR('/sfc/servlet.shepherd/version/download/...
cropredy's user avatar
  • 72.6k
16 votes
Accepted

ContentDocument parentId

You need the LinkedEntityId on the ContentDocumentLink
Fernando Gavinho's user avatar
15 votes
Accepted

How to Upload a File to a specific Library Folder using Apex?

As I can see from Your code while creating a ContentDocumentLink you are not specifying a LinkedEntityId. Linked entity ID tells in which folder it exists. So Minimum code needed to store file in a ...
Pranay Jaiswal's user avatar
14 votes
Accepted

how to upload files using Apex code

ContentDocument object does not allow insert DML operation in Salesforce, so we can upload it through the ContentVersion object, without ContentDocumentId. After DML on ContentVersion a new version ...
Jai Chaturvedi's user avatar
13 votes

Files as email attachment from Apex

If you have the ContentDocument Id you can fetch the ContentVersion file as this: // If you only want the ContentVersion ID's Map<Id, ContentVersion> contentVersions = new Map<Id, ...
Simonp's user avatar
  • 1,902
11 votes

ContentDocument parentId

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 ...
dacology's user avatar
  • 2,992
10 votes
Accepted

Open PDF in browser instead of Downloading

This was actually solved by setting the pdf filetype to 'Execute in Browser' from Setup -> Security -> File Upload and Download Security
G Takei's user avatar
  • 193
10 votes
Accepted

Where are the documents from the Documents tab in Lightning?

Documents are not available in Lightning Experience. You need to switch back to Classic to access them. https://help.salesforce.com/articleView?id=lex_gaps_limitations_files_and_content.htm&type=...
Jeff's user avatar
  • 929
10 votes
Accepted

Adding attachments in apex, convert the code to add Files

Lets add two methods first, one to create a ContentVersion record: private ContentVersion createContentVersion(String name, Blob body) ContentVersion contentVersion = new ContentVersion(); ...
Koen Wesselman's user avatar
9 votes

how to upload files using Apex code

I found a way to insert ContentVersion and attach it to Record in one SOQL. <apex:page controller="ContentController"> <apex:form> <apex:inputFile value="{!file}" /> ...
Kritik's user avatar
  • 266
9 votes
Accepted

ContentVersion Content-Type

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 ...
David Reed's user avatar
  • 93.4k
8 votes
Accepted

How to query a file uploaded as an attachment in lightning experience?

Files are stored in the ContentDocument Object .You will have to run a SOQL against contentDocument link first and look for all Content Version DocumentLink with EntityId as the ParentId of the ...
Mohith Shrivastava's user avatar
8 votes

Obtaining all ContentDocument records using SOQL

As advised by David Ha, you should add a "USING SCOPE" option in your SOQL query in order to retrieve all the ContentDocument records. Strangely, I found that "USING SCOPE Everything" restricts the ...
Sylvain's user avatar
  • 81
8 votes
Accepted

Is there a tool to run all tests and generate a coverage report?

You can use the ApexCodeCoverageAggregate object available in the Tooling API to obtain coverage information. However, this is not going to come down in an excel format. You can request this data in ...
dsharrison's user avatar
  • 4,002
8 votes

How to see anonymous code debug logs in visual studio code?

You can see the logs by Opening the Command Palette and enter sfdx get in the search box Then choose SFDX: Get Apex Debug Logs... After a few seconds, you are prompted to select a debug log to ...
manjit5190's user avatar
  • 8,063
7 votes
Accepted

How to share files uploaded in "Files" related list to Community Users

Files uploaded via this related list will only be visible to internal users, and this field is not editable. One thing you can do is post the file to the record via the Chatter publisher, and ...
citizen conn's user avatar
7 votes

Obtaining all ContentDocument records using SOQL

If you want to delete files that are related to a single object then export ContentDocumentIds from below query and then use those ContentDocumentIds to delete files which are related to object. ...
sfdc's user avatar
  • 13.7k
7 votes

What contributes to Salesforce File Storage?

As per Salesforce docs: File storage includes files in attachments, Files home, Salesforce CRM Content, Chatter files (including user photos), the Documents tab, the custom File field on ...
Tushar Sharma's user avatar
7 votes

How to upload larger size file using input tag of type html in LWC

You'll need to implement workarounds as of now if you need custom functionality w.r.t uploading files. The max content limit for AuraEnabled methods as mentioned by Pranay Jaiswal is 4MB, which is ...
Prashant Kashyap's user avatar
7 votes
Accepted

Uploading Multiple file using fileReader in lwc

Reading a file is asynchronous. This means that the upload code will happen before the files are read, and there won't be any files to read, so nothing happens. Instead, you need to wait for the files....
sfdcfox's user avatar
  • 500k
6 votes

Obtaining all ContentDocument records using SOQL

Official response from SFDC Support is this is working as designed. There is no ability to query all content programmatically via SOQL which I suspected. You have to query ContentDocumentLink with ...
CoryCowgill's user avatar
  • 2,203
6 votes
Accepted

How to prevent duplicate File (ContentDocument) if the same file is uploaded at multiple records?

Well, Apex does have that lovely heap limit of only a few MB so you can't compare the entire content of two large files. But the ContentVersion object does have a Checksum field. So in principle you ...
Charles T's user avatar
  • 11.1k
6 votes
Accepted

Body not a variable of ContentVersion?

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://...
Ryan Rudd's user avatar
  • 139
6 votes

Query to see all Files related to specific object (Events)

ContentDocumentLink, as you can see from that error message, has very strict requirements on how you can query it. You must supply a literal Id value or a set of Id values. This is a major limitation....
David Reed's user avatar
  • 93.4k
6 votes
Accepted

Is it possible to create a button to download all files attached to a record?

I don't think it would be possible easily in lightning. The sessionID in lightning is not API enabled, Thus you cannot access standard rest endpoint to download files. On top of that you cannot make ...
Pranay Jaiswal's user avatar
6 votes
Accepted

How to see anonymous code debug logs in visual studio code?

I would make sure you have an active User Trace Flag. I have noticed that in vscode sometimes you need to have your user trace flag set even when running anonymous apex.
Davis Handler's user avatar
6 votes
Accepted

Parsing JSON in apex - getting error System.StringException: Unrecognized base64 character: {

Your simplification of the JSON here is detrimental, and is obscuring the issue. For purposes of providing an answer, I'll assume that there is some Base64 encoded string somewhere inside of the JSON ...
Derek F's user avatar
  • 63.2k

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