Skip to main content

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
1 vote
1 answer
2k views

How to upload multiple files to ContentDocumentLink Object in one call from a lightning component?

I want to upload multiple files from a public site to salesforce ContentDocumentLink. How I can create bulk of files on javascript (client) side and handle them from apex? Lightning Component: ...
0 votes
2 answers
3k views

content version - clone from one object to another

I am trying to clone File(s) from a parent object to child. The code I am using is doing that but the file type is set to "LINK" while doing so, and I am unable to open that file or it has nothing ...
2 votes
1 answer
1k 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 ...
6 votes
1 answer
9k 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 ...
0 votes
1 answer
35 views

ContentDocumentLink Trigger referencing User Object for LInkedEntityID

I have a requirement to create an Email notification when an attachment is added to a custom object. I have seen other questions and resolutions here that reference the fact that LinkedEntityId cannot ...
0 votes
2 answers
3k views

Error while inserting contentdocumentlink with Collaborator access through Apex

I have a lightning component which executes an apex class on load. In apex class, I'm getting some list of files and providing 'Collaborator' access to the logged-in user if he is eligible. When I'm ...
0 votes
0 answers
13 views

How do you link to the uploaded file to an Assessment Question Response of data type File?

I want to link the uploaded file for this AssessmentQuestionResponse. In the Response Value field is the ContentDocumentId I tried using the AssessmentQuestionResponseId as the LinkedEntityId to ...
0 votes
0 answers
111 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 ...
1 vote
1 answer
5k 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. ...
1 vote
2 answers
1k views

Retrieve ParentID on insert of file

How to retrieve AccountId on insert of file. system.debug('LinkedEntityId $$$$'+LinkedEntityId) always gives OwnerId. But after insert of file, I can retrieve two rows from below query on ...
0 votes
1 answer
45 views

Need a SOQL query to retrieve files from Case object

The UI shows multiple documents associated with a Case. I am attempting to write a query to extract the documents. The query below is not pulling any results back. SELECT ContentDocumentId, ...
2 votes
2 answers
4k 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
63 views

ContentVersion is not visible but CDL is

The SharingPrivacy (File Privacy) is set as "Visible to Anyone With Record Access". I've a screen flow (running in system mode). This flow is on the Account record. It is supposed to get all ...
6 votes
4 answers
19k views

How to generate a download URL for a ContentDocument in Lightning Community

We're querying ContentDocumentLink for a list of documents related to a specific object record that the user has access to, and attempting to create a link for the community user to download that ...
0 votes
1 answer
1k views

Attach Files to a Big Object record

I would like to associate Files with Big Object records. Documentation inference implies this is not technically possible... if a Big Object could be a "LinkedEntityId" I imagine it would have been ...
0 votes
0 answers
46 views

Can't share a file because it's managed by library , How to share a library then?

i want to create a public link for a file , Class : public void execute(Database.BatchableContext BC, List<Challenge__c> scope) { Set<Id> testIsd = new Set<Id>(); ...
0 votes
0 answers
48 views

How can I create a public link for a content folder via Apex that opens the folder in Salesforce Lightning Experience?

I was trying to generate public link for content folder inside one of my library via apex. I am using following code snippet from anonymous window:- String folderUrl = URL.getOrgDomainURL()....
0 votes
0 answers
29 views

Content Note Owner loses access to edit Note after an edit by other user, wanted to retain the edit access for owner

If user A creates & owns the note and later other User B updates the same content note then after the update User A will not be able to edit the same note even though User A is the owner. [This ...
0 votes
1 answer
1k 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 ...
7 votes
1 answer
5k 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> ...
1 vote
1 answer
1k 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. ...
0 votes
1 answer
126 views

Nested query doesn't work

EDIT: I am using simple-salesforce with the REST API to make requests. I'm trying to get for each Case all the EmailMessages, and for each EmailMessage, all its ContentDocumentLinks (from which I can ...
0 votes
0 answers
39 views

Calling a flow that creates a list of uploaded files from an apex class is always one file behind

I am using a Flow to update a File_links__c on a record with the list of all the files for that record. This flow was originally a record-triggered flow. Editing any field in the record triggers a ...
0 votes
1 answer
53 views

Can visibility of Files related to sObject be restricted for certain users that have edit access to that object

We have Internal Financial Request object and Files related list. Let's assume there is two users user1 and user2 with edit access to a particular record of IFR. If user1 uploads file related to this ...
0 votes
1 answer
813 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 ...
0 votes
0 answers
798 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, ...
0 votes
0 answers
103 views

Cannot render pdf file in contentdocument in PDFjs viewer using salesforce URLs

I am creating a simple PDF viewer using PDFjs library (pdfjs-4.0.379-dist), where I have viewer.html and js in static resources, and pdf.mjs and pdf.worker.mjs library from CDN in viewer. Using CDN ...
0 votes
0 answers
228 views

SOQL nested query ContentVersion, ContentDocument, ContentDocumentLink

I am trying to access ContentVersion, ContentDocument, ContentDocumentLink to achieve a count of each contentversion per object. The relationships between the objects I activated QueryAll Document, ...
0 votes
1 answer
422 views

See what objects ContentDocument is linked to and get the count per objects

To keep it simple, I want to know to which Objects are linked my Attachments, so I executed the following SOQL query : select count(id), Parent.type counter from Attachment group by Parent.type I ...
1 vote
1 answer
273 views

Uploading a Content Version record using Postman with OwnerId field throws error

I have created a connected app which my client will be using to create cases in Salesforce. On testing the connected app using Postman I was able to get the access token, and also responses for SOQL ...
12 votes
2 answers
3k 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 ...
1 vote
1 answer
84 views

Error id value of incorrect type when inserting ContentDocumentLink

I know from the error that it is looking for the id of the contentdocument and not the id of the contentversion that got inserted. But I am just confused after inserting the files how do I get the id ...
0 votes
0 answers
45 views

get all stand alone FILES

I have a process of case auto deletion, and it seems that when a case is deleted and a file was attached to it, the file is not deleted in the same time. Q1: Is it possible that files remains in SF ...
0 votes
0 answers
81 views

Why can I create a ContentDocumentLink via Apex but not via DataLoader?

I am trying to copy data from one org to a sandbox via a backup tool and SF Data loader. Most things worked fine, but ContentDocumentLinks are missing. I tried loading them via Salesforce Data Loader, ...
0 votes
1 answer
60 views

ContentDocumentLink Trigger successfully blocks file upload on Org but fails in Dev Console

I want to block file uploads (ContentDocumentLink) on a FundingOpportunity object when status is Canceled or Closed. It works fine in the org, but it fails when I tried it on Dev console. A File is ...
1 vote
1 answer
589 views

Attempting to pass Flow variable to Apex to use in HTTP request & create PDF

I think I'm quite over my head in this class. I'm trying to do about three different things that are brand new to me. In short, I'm trying to do this : Pass a variable to an Apex class from a Flow (...
2 votes
1 answer
810 views

Create ContentDocumentLink after insert ContentDocument error

I have pretty simple requirement but I am facing error and I can't understand what is going wrong. I need to add ContentDocumentLink to add file to CollaborationGroup after insert with C permission. I ...
0 votes
1 answer
163 views

Inserting List of ContentVersions and ContentDocumentLinks at the same time

I'm looping through a list of records, creating content versions, adding to a list of content versions and then inserting the list of content versions. I then need to create a content document link to ...
0 votes
2 answers
3k 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
2 answers
93 views

Updating Account Object in Salesforce with Apex Trigger

I'm new to apex and trying to figure out how I can update a custom field on the Account object when a note is added. This is what I have for a trigger but the field isn't updating. I am not getting ...
-1 votes
1 answer
154 views

How to fetch file properties from Content document object using API

I am trying to get all the files attached to a case. I have found a way to download the files attached to case using sfc/servlet.shepherd/document/download/${contentDocumentIdLink}?operationContext=S1 ...
3 votes
0 answers
99 views

Mismatched LInkedEntityId on ContentDocumentLinks

I'm trying to link attachment files to Salesforce EmailMessages. Steps so far: Upload attachment file by posting to /services/data/v58.0/sobjects/ContentVersion. Query ContentVersion table to get ...
4 votes
3 answers
7k 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 ...
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 ...
3 votes
1 answer
2k 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 ...
-1 votes
1 answer
126 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)?
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( ...
0 votes
1 answer
256 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 ...
0 votes
2 answers
553 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 ...
10 votes
1 answer
9k 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@...

1
2 3 4 5