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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

a method in contentversion trigger return "List index out of bounds: 0"

i am making a content release trigger with a method to update the mobile business app for my work. The objective of all this is to send the data stored by the SNOTES and store it in the backend of the ...
user avatar
  • 21
0 votes
1 answer
29 views

Can't update ContentVersion. My code create new file every time

I had such issue. I created method that save attachent to my Opportunity. public PageReference attachInvoicePDF() { /* Get the page definition */ PageReference pdfPage = Page....
user avatar
  • 23
1 vote
2 answers
108 views

LinkedEntityId referring to custom object record id

Is it possible to map ContentDocumentLink (LinkedEntityId field) to a custom object record? As per the doc Documentation for LinkedEntityId, it has not been mentioned to be possible to reference a ...
user avatar
  • 3,705
1 vote
0 answers
46 views

Prevent creating new file while uploading new file from Salesforce standard upload button

Whenever a user uploads a new file under a particular record, I need to check for an existing file with the same name. If there is an existing file, then it should not create a new document; instead ...
user avatar
0 votes
0 answers
16 views

ContentDistributionTrigger after insert ContentDownloadUrl null

I have a ContentDistributionTrigger trigger after insert & update which when fired has a null value for ContentDownloadUrl. The ContentDistribution is created in a ContentDocumentLinkTrigger as ...
user avatar
0 votes
0 answers
14 views

Test class for files upload method using contentDocumentlink for Guest user [duplicate]

I was trying to write a test which will take input as a file upload field and store file onto a dummy record then attaching it to the Lead record and removing those dummy record data after attaching, ...
user avatar
0 votes
0 answers
35 views

Is it possible to have folders under the Opportunity / Notes & Files tab?

I tried to find out if it's possible to create folders where files can be stored, but all I can find is having the "File" tab separate and accessing the folders there through Libraries. Once ...
user avatar
0 votes
1 answer
29 views

Sorting ContentVersion based on Related objects like Account, Contact

I want to build a photo gallery where I can sort Images based on accounts, contacts or any other object. But not able to do so due to Data model of ContentVersion/documents. I can't sort ...
user avatar
  • 3,299
0 votes
0 answers
74 views

ContentDocument download in Community

It is now possible to download the file in Community through a link like this: https://[CommunityName].force.com/sfc/servlet.shepherd/document/download/[ContentDocumentId] But it only works for ...
user avatar
0 votes
2 answers
63 views

Update custom field on Opportunity on attached file deletion - Lightning

I have setup a trigger to update a custom checkbox Attachment__c on opportunity on uploading or deletion of file as an attachment. This seems to work fine on the file upload but fails every time on ...
user avatar
0 votes
0 answers
99 views

Create public link for external user on file upload

I am trying to create a public link for the external user to download the same file uploaded by him as guest user. So when an guest user upload a file and he try to download using "baseUrl/sfc/...
user avatar
  • 3,705
1 vote
1 answer
32 views

SOQL Subquery - Getting Cases that have updated ContentDocumentLinks (Attachments)

I have an integration that pulls cases using the following query. This works well. SELECT id, casenumber FROM case WHERE LastModifiedDate >= 2022-02-21T22:08:01Z AND LastModifiedDate <= 2022-...
user avatar
0 votes
2 answers
342 views

Trigger to check if a file is attached to a custom object record

I have a scenario where I need to check if a file has been added to a custom object record. If a file is already present, then the user should not be able to upload more files. Else, the user should ...
user avatar
0 votes
0 answers
116 views

Export all documents in content document / content version

We have a requirement where we need to periodically export all documents out of salesforce. I tried the following: Data loader / dataloader.io but then these gives export in csv file and the content ...
user avatar
1 vote
1 answer
121 views

Syncing Files between orgs (e.g. via Salesforce Connect's Cross-Org Adapter?)

Can anyone suggest a high-level solution for the use case of syncing Files between orgs (one-way is fine)? Preferably something that can be quickly POC'd. For us, Plan A would be to use the ...
user avatar
0 votes
1 answer
597 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"...
user avatar
0 votes
1 answer
319 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 ...
user avatar
  • 765
0 votes
0 answers
125 views

The field VersionData not queried in SOQL for ContentVersion sobject

I queried the ContentVersion object by following soql, VersionData field is not retrieved in results. SELECT Id, Title, VersionData, PathOnClient, ContentSize FROM ContentVersion WHERE Id=<Id> ...
user avatar
0 votes
1 answer
29 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, ...
user avatar
0 votes
1 answer
115 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 ...
user avatar
0 votes
1 answer
68 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 ...
user avatar
  • 13
1 vote
0 answers
174 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. ...
user avatar
  • 634
0 votes
0 answers
27 views

Error with ContentDocumentLink insert null pointer

I am trying to create a salesforce file and link to it.But when i run the code i get an error BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object on the line ...
user avatar
  • 1
1 vote
0 answers
49 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 ...
user avatar
0 votes
0 answers
94 views

File Delete Access to Certain Group of 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 ...
user avatar
0 votes
1 answer
203 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 ...
user avatar
0 votes
1 answer
32 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 ...
user avatar
  • 431
0 votes
1 answer
183 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 ...
user avatar
  • 6,634
0 votes
0 answers
98 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 ...
user avatar
  • 130k
0 votes
0 answers
108 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 ...
user avatar
  • 75
0 votes
2 answers
370 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=...
user avatar
0 votes
1 answer
67 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 ...
user avatar
  • 431
0 votes
0 answers
25 views

How to convert an incoming email HTML body into a Content Document?

I have a use case where the HTML body of an incoming case email is needed as reference on several different objects. It would be easiest to just convert the email body to a Content Document, but how ...
user avatar
1 vote
2 answers
2k 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 ...
user avatar
0 votes
0 answers
26 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; } ...
user avatar
0 votes
2 answers
843 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(...
user avatar
0 votes
1 answer
642 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 ...
user avatar
0 votes
0 answers
146 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. ...
user avatar
0 votes
0 answers
79 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(...
user avatar
  • 155
1 vote
1 answer
282 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....
user avatar
0 votes
0 answers
375 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. ...
user avatar
  • 599
0 votes
1 answer
95 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 ...
user avatar
  • 47
8 votes
1 answer
460 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 ...
user avatar
3 votes
1 answer
81 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 ...
user avatar
  • 2,688
0 votes
1 answer
178 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 ...
user avatar
  • 3
0 votes
0 answers
49 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 ...
user avatar
0 votes
1 answer
138 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 -...
user avatar
  • 5,445
0 votes
1 answer
78 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 ...
user avatar
0 votes
1 answer
126 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 ...
user avatar
2 votes
0 answers
93 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 ...
user avatar