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.
207
questions
0
votes
1
answer
349
views
Why does this query on ContentDocumentLinks work, when the LinkedEntity doesn't have record types?
When executing this query I'd expect this query to throw an exception, since the object does not have record types. but it doesn't. Why doesn't it throw an exception
SELECT Id,
(SELECT Id, ...
0
votes
1
answer
573
views
APEX Class invoked by flow to delete Content Documents, get DML exception on delete "ENTITY_IS_DELETED
I have made this simple class to assist a flow to delete content documents, it is working just fine in my apex tests but when I invoke it from a flow I get the following error message: 13:35:33:092 ...
0
votes
1
answer
78
views
How to run the code when the parameter was passed
I am facing the problem that I cannot run the code because there are no triggers to run it.
I need the pdf file to be previewed in the module window. Tried through conectedCallback and wire, it didn't ...
1
vote
1
answer
937
views
ContentVersion/ Content document link share files with partner users
I have a requirements that I need to share files with particular user which belongs to partner community user through trigger/apex code.
I am using the below hard to test. But finding some issue.
...
1
vote
0
answers
692
views
Give Delete Access on Attached files on case To Other Specified users
Whenever a Content Document is Uploaded on a record, I need to Share the file to a group of users and give delete Access to the same users.
I've Implemented a trigger to share the Document With the ...
0
votes
1
answer
1k
views
How to fetch the latest file in SOQL from each Order record
I am querying files from the list of Order records through SOQL. I have added my SOQL query below for your reference.
I want to query only the latest file which begins with 'IO_' from each Order ...
0
votes
1
answer
538
views
Query AccountId from LinkedEntityId
I would like a list of all files which are concerning to a account record, but my files have only a relation to the contacts. How can I query all files of the account?
The LinkedEntityId is from a ...
0
votes
1
answer
959
views
How to access files from a particular folder in a library to send it as attachments through an email?
I am trying to find a way to query files from one of the folders in a library. I am seeing there is no strong direct relationship between library and folder it seems. My use case is, I need to query ...
0
votes
0
answers
336
views
Anyone using sfdx force:data:bulk:upsert to update Files (ContentDocument/ContentVersion)?
I have some small place-keeper files (ContentDocument/ContentVersion) loaded by some existing code but want to replace the content with the actual PDF/Video data. This is to pre-load scratch orgs with ...
0
votes
0
answers
517
views
Content Version's Content Size
i am unable to pass values to Content Version's ContentSize Field.
i am getting this compile error:
Field is not writeable: ContentVersion.ContentSize
here is my sample code:
trigger ...
0
votes
2
answers
1k
views
How to query the Content Id of a File?
After creating a public link of a File using ContentDistribution, you get the below URL
https://--c.documentforce.com/sfc/dist/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=...
0
votes
1
answer
147
views
Testclass for wrapper class implements Comparable and contentdocumentlink
I don't know how can I test my contentdocumentlink, in the log I got the information
EXCEPTION_THROWN [18]|System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by ...
1
vote
2
answers
6k
views
Attach File (ContentDocumentLink) to Email
I'm creating and sending one email via APEX.
However I havent found any documentation helping me to attach a File (ContentDocumentLink), not an Attachment to an Messaging.SingleEmailMessage.
The query ...
0
votes
0
answers
35
views
ContentDocumentLink query not working with dynamic Id
Im trying to querry the ContentDocumentLink object and althogh I have a ContentDocumentId with a valid ID it wont populate the querry.
for(ContentDocument cd: newList){
derp = cd.id;
}
...
1
vote
2
answers
3k
views
How to export all the ContentDocumentLink records in Salesforce?
I am doing analysis to get the number of files attached to the each object inside Salesforce.
I found that there is a standard object named ContentDocumentLink which has the reference of the each file(...
0
votes
1
answer
1k
views
Community User cannot download or preview docx file LWC
The url for preview and download of a docx file is not working on Community.
The ContentDocumentLink is connected via the LinkedEntityId field to a custom sObject called SupportingDocuments__c, which ...
0
votes
0
answers
713
views
"Internal Salesforce.com Error " (FATAL ERROR) During a Batch class run on creation of opportunity products
We have created a Trigger on Content Document link Object which has a handler class which in turn calls a batch class.
The process is when a user upload a csv file it will create opportunity product.
...
0
votes
0
answers
270
views
Unit Testing for ContentDocument processes
Here is my testclass:
ContentVersion contentversion = TestDataFactory.createContentVersion('test', 'test', 'test');
Set<Id> testSet = new Set<Id>();
testSet.add(...
1
vote
1
answer
589
views
Apex Mocks test error for Domain class
We have been using FFLIB(Apex commons) in our org.I have been trying to write a test case for a Content Document Link (Salesforce Files)Domain layer But i have been getting the error : "System....
0
votes
0
answers
1k
views
Triggers on the Files Object
I have a trigger on the ContentDocument when all the files associated with the Parent record is deleted it should uncheck the check box field (Files_Exists__c) on Parent saying no files exists not. ...
0
votes
1
answer
515
views
Why every ContentDocument have two ContentDocumentLinks?
I working with documents in salesforce and I notices that every file I uploaded have two ContentDocumentLinks. In this links one LinkedEntityId is id that I set when uploading the file, but the second ...
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
1
answer
160
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 ...
0
votes
1
answer
509
views
Rerender files related list on opportunity record page after creating content document link
I use a LWC on an opportunity record page to create a pdf document that is then converted to a base64 string. From this a ContentVersion object is created and a ContentDocumentLink from an imperative ...
0
votes
0
answers
193
views
Content Document Link Error
I am getting 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 ...
0
votes
1
answer
323
views
Get the owner of the file from ContentVersion? - How to Merge 2 queries
I am querying for some data on a contentversion record, and also need to get the ContentDocumentId owner.
I have these 2 queries, that work.
But, is there a way I can do it in a single query?
Query 1 -...
0
votes
1
answer
367
views
Relating multiple cases to a content note
I am basically trying to relate a note record to multiple cases. I understand that when I am trying to create a note it basically creates ContentDocument, ContentNote, and ContentVersion. I am not ...
0
votes
1
answer
356
views
It is unable to get of an apex class for getting ContentDocumentLink.LinkedEntityId from the following code?
I need an apex class to get a standard object called Contentdocumentlink field called LinkedEntityId.
when document upload. It should automatically create a task.
I'm unable to get ...
3
votes
0
answers
340
views
ContentDocumentLink SOQL doesn't return all rows
I have the same question as this one (but couldn't comment on it)
To reproduce the issue:
Map<Id, Contract> limitedContracts = new Map<Id, Contract>([
SELECT Id
FROM Contract
...
2
votes
0
answers
221
views
File not showing preview when created by Force.com Site Guest User (i think after Summer '20 Release)
I saw that since Summer 20 changes to the rights of the Force.com Site have taken place (https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_networks_guest_user.htm)
Currently I ...
3
votes
1
answer
711
views
ContentDocumentLink trigger not running
I've been trying to track down why a ContentDocumentLink trigger is not running in a specific case. In the working cases we have code that inserts ContentDocumentLink records, but in the failing case ...
3
votes
1
answer
4k
views
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY : [NetworkId]
I've written a simple trigger to enforce our Community users not to delete files. Currently, I'm facing an issue in getting test coverage for deployment.
Trigger
trigger ContentDocumentTrigger on ...
0
votes
0
answers
666
views
How to add a new image file into ContentVersion using Apex?
I have a URL which is a PNG file which is hosted on external cloud and I would like to create a new file with this image in my salesforce opportunity object as a file. Could anyone point me on how to ...
0
votes
1
answer
226
views
Trigger on ContentDocumentLink gets fired for current user in test class
I am trying to increase test coverage of an after-trigger on ContentDocumentLink. The problem is that the trigger gets fired twice. I found out from this answer that the trigger fires one extra time ...
0
votes
2
answers
2k
views
How to delete a ContentDocumentLink
I wan't to create a ContentDocumentLink and delete him in an other function, i tried this code:
// function of creation:
ContentDocumentLink cdl = new ContentDocumentLink(
ContentDocumentId = doc....
0
votes
1
answer
2k
views
Retrieve the Record type name of the Related entity ID in Trigger
I am trying to get the record type name of the related/linked entity id in the trigger of the Content Document Link like below
trigger setVisibilityOnNotesinCase on ContentDocumentLink (before insert) ...
2
votes
0
answers
809
views
SOQL Query Returning Zero Rows on ContentDocumentLink (filtering on LinkedEntityId)
For my specific use case, I need to find all Content Documents on specific object records that meet a
business requirement. However, when I filter by linkedEntityId on the contentDocument my soql ...
1
vote
1
answer
198
views
Connect REST api to add existing file to existing folder -- like ContentDocumentLink
I'm (successfully) uploading a file to the
/connect/communities/{community}/files/users/me endpoint.
I'm able to share that file with a specified user by creating a file share
/connect/communities/{...
-1
votes
2
answers
732
views
System.QueryException: Implementation restriction: ContentDocumentLink?
I have been following this to create a lightning component for lighting:file upload. As you can see there's comments on how to avoid the System.QueryException yet I still am getting it?
picture of ...
0
votes
1
answer
119
views
Mock Callout fails when DML in ContentDocumentLink
I have a class where I am reading content from the DB and using the info I read to call out. I actually make 2 callouts (one to authenticate and one to upload).
When I insert a record of ...
2
votes
1
answer
873
views
Delete a ContentDocumentLink of Library file
I have inserted a file in Library. I want to delete the ContentDocumentLink by which it is shared with the Library. I have created new ContentDocumentLink where I have shared file with a user. But ...
1
vote
2
answers
2k
views
How to upload file inside a folder inside a Library through apex?
Suppose I have a library named xyz and a folder inside it named abc. I am able to insert a file into the library through the apex via the Content Document link. But how to move the file to a folder ...
3
votes
1
answer
1k
views
Create new ContentVersion with ContentDocumentLink to non-user only
Every time I create a new ContentVersion without ContentDocumentId it automatically creates a ContentDocumentLink that is linked to the user. I just want it to link to an Opportunity so I'm not sure ...
0
votes
1
answer
879
views
Moving trigger on Attachments to Files
We are transitioning our org to LEX and there is code that has to be updated from Attachments to Files...i.e. ContentVersion, ContentDocument and ContentDocumentLink. One of the updates is a trigger ...
0
votes
1
answer
219
views
addError message is firing in one sandbox but not firing in other sandbox
I have a requirement that users should not be able to remove document from the closed cases. I have achieved this by writing a trigger on before delete on contentdocumentlink.
My old code was like as ...
1
vote
0
answers
377
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,...
4
votes
1
answer
8k
views
How to download files, documents (attachments) in salesforce via apex?
I want to download all files associated with records (single or multiple records) of a particular object at one click, using apex.
Let's say that there is a custom object myVehicle which holds ...
0
votes
2
answers
1k
views
Prevent files from being duplicated ContentVersion - ContentDocumentLink
I have button, when click on it, it'll generate a doc and stock it in Files
I want to > when i click on that button again, the doc will not be duplicated
Code
ContentVersion contVer = new ...
0
votes
1
answer
700
views
Inserting contentdocumentlink in contentdocumentlink trigger throws errorDocument with ID: xxx is already linked with the entity with ID: xxx:
the requirement is when an file is added not uploaded to event that is associated with some opportunity, i want that file gets associated with opportunity as well And when we add a file "it somehow ...
0
votes
1
answer
88
views
How to subscribe to a ContentDocument using API?
I am trying to develop a Custom UI for subscribing ContentDocument and found out that we have ContentSubscriptionObject which stores subscription information of the document.
However we cannot insert ...