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
25 views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You don't have permission to share this file.: [ContentDocumentId]

I am Facing this issue only while executing the below code in the Guest User context, how to resolve it? The exeption occurs while inserting contentDocumentLink Record. ContentVersion cv = new ...
Satyendra Raghuvanshi's user avatar
-1 votes
0 answers
23 views

How to find all Contacts associated with a ContentNote

I need to identify all Contacts in an org who are associated with a ContentNote. Unfortunately, I can't query ContentDocumentId directly without a list of Ids to filter against. Creating a report ...
Michael Sobczak's user avatar
-1 votes
1 answer
28 views

How to make an attached document to record visible only for the owner

How to make an attached document to record visible only for the owner of record (custom object) and not visible for other users (for wish record is visible)?
Pedro Van's user avatar
0 votes
1 answer
36 views

Guest User cannot edit ContentDocument

We have a system in place to allow guest users (under some circumstances) to modify files in Salesforce (those pesky ContentDocument and ContentVersion records). This system works in the development ...
AvailableName's user avatar
0 votes
2 answers
97 views

How to write a Scheduled Flow to count how many Notes are related to an Account record?

I'm trying to write a Scheduled Flow to count how many Notes are related to an Account record. I have a Scheduled Flow on Account that is configured to walk through all Accounts every day. The first ...
Jack Odell's user avatar
4 votes
1 answer
78 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 "...
Phil W's user avatar
  • 33.4k
0 votes
0 answers
32 views

i am trying to upload and store files in multiple collections in Screen Flow but its not assigning ContentdocumentLink in Assignment

I am working on Screen Flow. and i want to upload multiple files and also to store multiple file in related Record Id. as i am doing with content document link i need to assign and add single content ...
Tushar Kumar's user avatar
0 votes
2 answers
128 views

What is the order of execution in content related objects?

I have a scenario to insert the content document link for sharing the contentdocument with contentworkspace (library) when the contentdocument is created. I want to write a trigger to achieve this. I ...
riseAJdev's user avatar
0 votes
0 answers
22 views

List only accounts with documents attached

I have the following query to get the list of accounts with documents attached to them. I need to filter by opportunity StageName: select id, (Select Id, StageName From Opportunities),(Select ...
user1282441's user avatar
0 votes
1 answer
351 views

Is there a createdDate field on ContentDocumentLink?

I try to query the newest ContentDocumentLink on a record. My approach is pretty simple. I want ORDER BY CreatedDate and LIMIT 1. ContentDocumentLink cdl = [SELECT Id FROM ContentDocumentLink WHERE ...
Gerke's user avatar
  • 147
0 votes
0 answers
103 views

Unable to delete ContentDocumentLink from record

This is all on a Salesforce Community. i have made lwc component where i want to remove record from knowledge article but it is showing null pointer exception. Firstly i am changing the owner and ...
Dhiren Raut's user avatar
0 votes
1 answer
334 views

Another ContentDocumentLink, ContentVersion & ContentDistribution Question

I apologize if this has already been covered (It probably has, I just cant find it in the 'Open your eyes' section of the forum) But I'm having troubles creating a list of publicly accessible URLS ...
Mike Cuming's user avatar
0 votes
1 answer
56 views

Account Documents

I am using the following SOQL query to get the documents attached to an account: select LinkedEntityId , ContentDocument.Title , ContentDocument.ContentSize ,ContentDocument.Description , ...
user1282441's user avatar
0 votes
1 answer
322 views

Content Document Parent ID Salesforce

I am completely lost on how to populate a ParentID for Content Documents. I would like to find the parent record (custom object record) linked to the Content Document. I have easily sorted it in the ...
Victoria Aroworade's user avatar
0 votes
0 answers
124 views

How to Append Content Document title in Salesforce

So I'm having an issue where MS teams invites are being sent to CASE queues for group meetings. This results in with a file being created which gets downloaded sometimes and sent to others. The file ...
Cody Barnes's user avatar
0 votes
2 answers
52 views

Query for Related Attachments works in query editor but not Apex

I am trying to make a simple APEX Class that returns a records related attachments. When I do the following SOQL query in the Query Editor I get the 3 expected results: SELECT Id FROM ...
Austin Kelly's user avatar
0 votes
0 answers
66 views

Not able to call apex method from LWC in lightning flows

I am trying to call an apex class which returns a list of a wrapper class consisting of contentVersionID, filename, documentID, custom URL, and document_Type__c. I introduced the LWC component in the ...
ADITYA VAIBHAV's user avatar
0 votes
0 answers
63 views

ContentDocumentLinks subquery stopped working

I previously had this code and it was working (ContentDocumentLinks as related list subquery): List<Id> recordIds = new List<Id>{'0032200000SRusR'}; List<Contact> contacts = [ ...
Mariia Illarionova's user avatar
2 votes
1 answer
119 views

Help with sorting content documents by custom field on its LinkedEntity

This SOQL statement works, but I'm trying to sort the Content Documents by a field e.g. Sort_Order__c on Invoice__c. SELECT ContentDocument.id,LinkedEntity.Name,LinkedEntityId FROM ContentDocumentLink ...
Dan Hardy's user avatar
0 votes
1 answer
54 views

Share LinkedEntityId with grandchild

I am trying to share a file with a grandchild record. Parent: Account: Child of Account: Contact Child of Contact: Invoice if(Trigger.isInsert){ Set<Id> getAccts = new Set<Id>(); ...
Phuc's user avatar
  • 407
0 votes
1 answer
414 views

Can't add 1 file to object

I have the requirement to create a validation rule that only allow you to set the status in closed won if a file is attached to the opportunity. To achieve this, I have created a custom field which is ...
Jav's user avatar
  • 13
0 votes
0 answers
96 views

ContentDocumentLink and ContentVersion Migration from Org source to Target

As part of a migration project, I want to migrate all contentVersion and contentDocumentLink from an Org A to an Org B. my files are spread over 7 custom objects and 3 standard objects I want it to be ...
Amir Bouzid's user avatar
0 votes
1 answer
82 views

Post request with polymorphic field on the body

I am trying to send a post request to ContentVersion to migrate my contentVersions from point A to B : i build the body like this : body = ('{"Title" :"'+Title+'", &...
Amir Bouzid's user avatar
1 vote
0 answers
269 views

Display folders for an object according to a picklist value using lwc

Hi all I have an object name FS where I have uploaded various files in each records. Also in the content version record I have a picklist value named Category which has certain picklist values New and ...
user121495's user avatar
1 vote
1 answer
2k views

How to give Community Portal user access to view ContentDocument

I have a Lightning Web Component, its job is to return all the documents related to a record. I have tested the web component by running it internally and it looks like it is performing as expected. ...
Simple Code's user avatar
2 votes
0 answers
434 views

Visibility InternalUsers is not permitted for this linked record only in Test context

I am receiving the following message when trying to insert a ContentDocumentLink in a trigger but only in test context : Visibility InternalUsers is not permitted for this linked record I checked ...
THEDJA's user avatar
  • 125
0 votes
0 answers
485 views

DLRS: How to count all Files (without Notes) related to an Opportunity?

I created a DLRS (Declarative Lookup Roll-up Summary) on the Opportunity that counts how many Files are related to it. However, the count gives me both the Files+Notes and I only want the File count, ...
Lut's user avatar
  • 269
2 votes
1 answer
346 views

Apex Error "Too Many SOQL Queries" with Trigger on ContentDocumentLink

I'm getting the "Too many SOQL queries: 101" when executing a test class. I'm not even getting into my test method - it's failing on the test setup. When it fails, it's failing in my trigger ...
Jeff's user avatar
  • 111
0 votes
2 answers
932 views

INVALID_CROSS_REFERENCE_KEY : Invalid cross reference id in After insert Trigger to create ContentDocumentLink

I am encountering the following error when inserting a ContentDocumentLink record : Error [statusCode=INVALID_CROSS_REFERENCE_KEY, code=[xmlrpc=1202, statusCode=INVALID_CROSS_REFERENCE_KEY, ...
THEDJA's user avatar
  • 125
0 votes
1 answer
1k views

Using the API How can i get "file" attachment. I am able to get "attachment" correctly

I am able to list and download any item that the Type=Attachment with no issue. I can get a list of items where the Type=File. How can I Download the items that are Files? I am using Salesforce ...
bart2puck's user avatar
  • 127
0 votes
1 answer
643 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....
Yauheni's user avatar
  • 29
1 vote
2 answers
2k 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 ...
Anu's user avatar
  • 3,777
1 vote
0 answers
268 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 ...
Ajith Kumar's user avatar
0 votes
1 answer
195 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 ...
Jurgen Palsma's user avatar
0 votes
1 answer
562 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 ...
Anna Spasova's user avatar
0 votes
1 answer
526 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 ...
Manjot Singh's user avatar
  • 3,404
0 votes
2 answers
412 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 ...
Sachin Prasad's user avatar
1 vote
1 answer
445 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-...
Bryan Harrington's user avatar
0 votes
2 answers
2k 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 ...
Roman Regmi's user avatar
0 votes
0 answers
948 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 ...
Avinash Kumar's user avatar
1 vote
1 answer
446 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 ...
Brent Bowers's user avatar
  • 3,064
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"...
SFDC_Beginner's user avatar
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 ...
Andrew L.'s user avatar
  • 837
0 votes
0 answers
436 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> ...
Satishakumar Awati's user avatar
0 votes
1 answer
287 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, ...
PartOfTheOhana's user avatar
0 votes
1 answer
521 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 ...
Daniel Wretman's user avatar
0 votes
1 answer
77 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 ...
Slavik's user avatar
  • 25
1 vote
1 answer
808 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. ...
SFDC 44's user avatar
  • 664
1 vote
0 answers
585 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 ...
Haribhanuprasad Nandarapu's user avatar
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 ...
Akshay Vasu's user avatar

1
2 3 4 5