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:...
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 ...
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
/...
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/...
16
votes
Accepted
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 ...
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 ...
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, ...
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 ...
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
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=...
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();
...
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}" />
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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....
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 ...
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 ...
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://...
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....
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 ...
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.
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
files × 503apex × 116
contentversion × 78
contentdocument × 73
attachment × 58
contentdocumentlink × 49
lightning × 44
lightning-web-components × 31
rest-api × 31
community × 30
fileupload × 29
visualforce × 28
lightning-aura-components × 28
trigger × 24
content × 24
soql × 22
sharing × 15
pdf × 14
upload × 13
api × 12
lightning-experience × 12
chatter × 12
libraries × 11
chatter-file × 11
file-storage × 11