Questions tagged [contentdocumentlink]
Use this object to query the locations where a file is shared or query which files are linked to a particular location.
27
questions
51
votes
7
answers
48k
views
Obtaining all ContentDocument records using SOQL
According to the Salesforce documentation on ContentDocument
Users (including users with the “View All Data” permission) can only query files they have access
I find this very strange. Why would a ...
10
votes
1
answer
10k
views
How to Upload a File to a specific Library Folder using Apex?
I am trying to save a Visualforce page as a PDF file to a Library folder in our Salesforce org. I have been unable to figure out how to save this new PDF file to a specific Library folder.
I tried ...
8
votes
1
answer
647
views
Weird Behaviour of Bulk ContentDocumentLinkTrigger in Test Context
I know that ContentDocumentLink triggers are not bulkified by Salesforce. I was expecting that behavior and was writing test classes accordingly.
It looks like, ContentDocumentLinkTrigger doesn't ...
10
votes
1
answer
7k
views
How to create an EmailMessage record with DML having HasAttachment to be 'true'?
I'm creating EmailMessage records via DML
EmailMessage createWhatEmail = new EmailMessage(
Subject = 'test'
,Status = '3'
,ToAddress = 'heim@...
8
votes
1
answer
1k
views
ContentDocumentLink query returns different results based on LinkedEntityId size
If I want to find how many files are related to a given object (ex. Account), I could do the following two queries (assuming you don't hit a 50,000 row limit - this is just an example).
//get accounts
...
3
votes
3
answers
6k
views
Unable to delete ContentDocumentLink
This is all on a Salesforce Community.
I have a situation where a user is uploading a file and it's temporarily assigned to their user record. Once they submit the form and it creates a custom object ...
12
votes
1
answer
2k
views
How to distinguish between ContentDocument and ContentNote?
There seems to be some unusual stuff going on with SObjectType for the enhanced note ContentNote (ERD) object and the underling ContentDocument (ERD) structure.
For example, both these return a ...
7
votes
1
answer
4k
views
Entity 'ContentDocumentLink' is not supported for semi join inner selects
Why doesn't Salesforce support semi join selects on the ContentDocumentLink entity?
Why would there be a random entity that doesn't work like all the others?
This code:
List<ContentVersion> ...
7
votes
4
answers
4k
views
Why SingleEmailMessage.setFileAttachments() does not create visible attachments in the Activity Tab in Lightning Experience
I'm sending emails like this:
Messaging.SingleEmailMessage m = new Messaging.SingleEmailMessage();
m.setToAddresses( new String[]{'[email protected]'} );
m.setSubject( 'test' );
m.setHtmlBody( ...
6
votes
1
answer
8k
views
ContentDocumentLink Apex after insert trigger error
Edit: I've built an after insert trigger on ContentDocumentLink. On cropredy's direction, I've bulkified my code and I think improved it generally. It "works" in that it accomplishes my ...
4
votes
1
answer
511
views
Why is this ContentNote trigger receiving 1 record at a time even though multiple records are being inserted?
I am seeing a ContentNote trigger called on individual rows even though a bulk insert is done. A stripped down version follows.
The debug log output demonstrates that 3 ContentNote objects are ...
4
votes
1
answer
125
views
How can I prevent a ContentDocument being deleted when it is linked to a record meeting certain criteria?
I have ContentDocuments being used to capture "proof" against certifications. Once the submitted certification (and "proof") has been reviewed, that certification is marked "...
3
votes
1
answer
3k
views
ContentDocumentID is not available just after ContentVersion getting inserted But available after soql query
I am inserting ContentVersion as following:-
String yourFiles = 'Lets assume this is your binary string of the files';
ContentVersion conVer = new ContentVersion();
conVer.ContentLocation = 'S'; // S ...
3
votes
1
answer
155
views
Incorrect result for ContentDocumentLink query
I'm trying to query all the ContentDocumentLinks related to a list of about 25000 accounts. This yields no results. However, if I limit the initial account query to only 800 accounts I do find a ...
3
votes
1
answer
17k
views
How to query ContentDocumentLink in SOQL and then upsert records in Data Loader
When querying ContentDocumentLink in SOQL using the following query, an error is thrown.
Goal: We are attempting to get a spreadsheet of the data so we can update IsDeleted flag with TRUE on entries ...
2
votes
1
answer
3k
views
ContentDocumentLink filter not working- Trailhead Conference Management App
Im facing below error:
Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id's using the IN ...
2
votes
2
answers
3k
views
Move a ContentDocument from one library to another in Apex
Is there a direct way to do this in Apex?
I tried doing DML to ContentDocumentLink or ContentWorkspaceDoc. But nothing works.
What I tried so far
Update the Library in ContentWorkspaceDoc
...
2
votes
1
answer
2k
views
Public guest user can't access ContentDocuments
I have a site with a Visualforce page that requires access to ContentDocuments linked to an Opportunity. My problem is that i can only see, as a public guest user, content documents that are uploaded ...
1
vote
1
answer
3k
views
ContentDocumentLink fires trigger multiple times on list insertion [duplicate]
We have a trigger on Order attachment insertion, so that a field is populated with a link to the attached documents whenever a user uploads one or multiple files to an existing Order.
We created the ...
1
vote
3
answers
15k
views
ContentDocumentLink insertion fails
I want to share all records with admin user using next trigger:
trigger ContentVersionTrigger on ContentVersion (after insert) {
system.debug('sdfsdf' + Trigger.new);
for (ContentVersion ...
1
vote
0
answers
373
views
ContentDocumentLink Limitations when querying using LinkEntityId as filter
my apologies if this has been asked somewhere else. I didn't find any answer hence I have to post this question.
USE CASE:
I am using database.query(queryString);
In queryString = 'SELECT id,...
0
votes
1
answer
2k
views
Problem Querying Fields on ContentVersion When User is not the Owner
UPDATE
This can reproduced in any org, so it may be designed behavior or a bug. Basically, if a user is not the owner of a ContentVersion record they will only be able to filter by Id or ...
0
votes
1
answer
4k
views
How to view the content Document in Lightning Community
I have an option to Upload the document in the community Portal.
<lightning-input type="file" onchange={handleFileChange} name="uploadFile" multiple label="Attachment"...
0
votes
0
answers
672
views
How to use current record Id (In after insert trigger) to save it in some different object?
Please find my scenario below
I will talk in generic words so that the objects name should not confuse someone.
I have written after insert trigger on an object and obviously, I am getting the Id of ...
0
votes
1
answer
254
views
Batch Apex creating Multiple contentdocumentlinks when trying to "convert" tasks to notes...
I am trying to look at all tasks for a specific time frame, then create a note and set the LinkedEntityId to the whatid or whoid. This code creates the content note, 1 for each task. But then created ...
0
votes
2
answers
9k
views
Error with ContentDocumentLink insert
I am receiving this error when I try to create a Note and inserting it to an opportunity. The opportunity is valid and there is no documentation of requiring the field, "document" for ...
0
votes
1
answer
761
views
Attachment downloaded as type file
I have below code to add content document versionData into standard attachment.
Map<Id, Blob> bodyContent = new Map<Id, Blob>();
List<ContentVersion> contentDocs = [SELECT ...