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
0answers
11 views

ContentDocumentLink fires trigger multiple times on list insertion

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 ...
0
votes
1answer
23 views

How to add a filter in query to only fetch specific files

I am running a SOQL query on contentversion to fetch files that are attached to opportunity. However, I am noticing that it is even pulling the notes attached to the opportunity as well. Is there a ...
0
votes
2answers
36 views

How to copy LinkedEntityId/Opportuntiy id in Content version object via Apex trigger

I have created a custom field(lookup field to opportunity) on Content version object that would denote the opportunity id that file is connected to. The custom field is Opportunity__c. Here is the ...
1
vote
1answer
405 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
1answer
27 views

How do I display Opportunity ID/LinkedEntityID in content version object

I am running a query on contentversion to fetch files related to opportunity from Salesforce. However the content version records returned from the query does not tell me what opportunity id is that ...
0
votes
1answer
45 views

How to create a nested query that fetches opportunities, Content Document and Content Version [duplicate]

I am trying to fetch all files that are associated with the opportunities in 'XYZ' stage. I am trying to construct one nested query that would first fetch all the opportunities in that stage, then ...
5
votes
0answers
794 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@...
0
votes
2answers
34 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
1answer
72 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 ...
7
votes
1answer
384 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 ...
0
votes
0answers
33 views

Test class coverage issue for calling email template and inserting email message

I have written test class for the below Apex Trigger but still cannot get the coverage for calling email template and inserting outgoing email message.How can i test them using apex. Apex Trigger ...
0
votes
1answer
27 views

Linking ContentDocuments to Products

I am looking to associate ContentDocuments to Product2 records based on values in the ContentVersion record. For example I am uploading a new File record in Salesforce that is a document about ...
1
vote
2answers
62 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 ...
0
votes
0answers
36 views

Error while inserting a new revision of a file programatically

I am trying to upload a new revision of a file in ContentVersion object programmatically by Apex. I am getting the below error while inserting a new record of ContentVersion. 15:21:52:424 ...
0
votes
1answer
347 views

Insert ContentDocumentLinks for Chatter Content Posts

We have a set of ContentVersion records that have been inserted by users via a FeedItem post. Unfortunately because Chatter groups has many functional limitations we have to migrate these files to ...
0
votes
1answer
18 views

Documents in Salesforce Customer portal behind login

We have a Customer portal that our member log into. Once they log in they have access to a documents library which are are held in the Static Resources section. I have a document that we will want ...
1
vote
1answer
90 views

Deleting 'Files' in Lightning Experience

As per Salesforce documentation 'Files' (ContentDocument) can be deleted only by the user who created them. In order to provide access to delete a file created by other users, Salesforce recommends ...
0
votes
1answer
39 views

How to create a new contentversion(pdf) using the existing contentversion(word) version data

I want to generate the pdf file using word document. I was trying to create the new contentversion(pdf) using the existing contentversion(word) versiondata. However, the pdf is not opening after ...
1
vote
2answers
1k views

How Content Document Should be Associated with Custom Object

I am trying to create File through ContentDocument . Once File is created want to associate with Custom Object Want to understand what is best way to associate File with Custom Object Use FeedItem ...
4
votes
0answers
357 views

How can you insert a Salesforce File with Collaborator ShareType?

I am currently trying to insert a Salesforce File attached to a custom Invoice object with the Collaborator (C) permission, as described on the Salesforce Documentation. The code was originally set ...
0
votes
0answers
100 views

SF Integration unable to add attachment from Docusign

Hi guys i just wanna ask what is this error from Docusign. I've tried to use Salesforce connect for our app in order to save the completed document in notes and attachment. But everytime I complete a ...
0
votes
0answers
19 views

How to access ContentDocument to be used as attachment in visualforce email template

How to access ContentDocument to be used as attachment in visualforce email template <messaging:attachment filename="{!relatedTo.ContentDocument.Title}" renderAs="{!relatedTo.ContentDocument....
2
votes
2answers
146 views

ContentVersion FileExtension

Does anyone know how I can change the FileExtension for a new ContentVersion in a test class? Im currently trying to create a test class for my ContentDocumentLink Trigger, in which I have an if ...
0
votes
1answer
51 views

How to generate an external downloadlink for files

I have created a visualforce page (site) with a dowloadlink from files. I can use this when I am logged in into Salesforce. I want to achieve this for external users by a site. In salesforce It is ...
2
votes
1answer
413 views

How to query ContentDocument and Custom object's fields at once?

We have 3 objects. OS_Account_Document__c (Custom) ContentDocument ContentDocumentLink I need to query two custom fields (Document_Type__c and Custom_Document_Description__c) from the Custom Object ...
2
votes
2answers
715 views

ContentNote not inserting

I am trying to insert a new ContentNote and link it to an opportunity with ContentDocumentLink. However, after inserting the content note, the ID returns as NULL, so referencing it in the ...
5
votes
2answers
532 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 ...
2
votes
1answer
176 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 ...
0
votes
1answer
239 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: ...
1
vote
2answers
752 views

Community user cannot download file

I am using an old portal for my customers, with customer community user licenses. In the portal, my users should upload files and then download the files that they have uploaded. The portal is ...
1
vote
0answers
95 views

How to bulk query ContentDocumentLink for Scheduled Job

I have a trigger that fires on the ContentDocumentLink object that then calls a REST Webservice. The logic basically places a users document into our Document Management System from Salesforce and ...
0
votes
1answer
221 views

Could not able to retrieve VersionData from Content Version after insert of ContentDocument

I am trying to retrieve the body of ContentDocument after insert. Below is my code.My trigger is on ContentDocument (After Insert) public static void syncContentDocument(List<ContentDocument> ...
1
vote
1answer
129 views

System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by a single… in test class?

I'm facing System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id's ...
0
votes
1answer
196 views

how can i query all attachments related to a case?

I need to be able to query for all attachments related to a single case, even the attachments related to emails on the case. I also need it this code to get all attachments if there are multiple ...
1
vote
0answers
214 views

Not able to create ContentDocumentLink FIELD_INTEGRITY_EXCEPTION

Trying to create a Content Document Link linking a text file to a custom object (an error log object). But keep getting the following error: First error: Insert failed. First exception on row 0; ...
0
votes
0answers
35 views

Permission Error when Auto-Sharing Salesforce File with Apex Trigger

I am trying to create an Apex trigger that automatically shares an attached Salesforce File with a user related to the record upon which the File was uploaded. I believe I have created a working code ...
1
vote
0answers
21 views

INVALID STATUS on ContentVersion create from Attachment [duplicate]

I'm currently trying to create ContentVersion records from Attachment ones but it's giving me the following error: INVALID_STATUS, Documents in a user's private library must always be owned by that ...
0
votes
0answers
28 views

Can I get a public link to an attached PDF?

We have a 3rd party that is generating PDF quotes, and attaches these to a (custom) quote object. I'd like to generate public links for these so they can be emailed to customers - but from https://...
0
votes
1answer
572 views

APEX - Get ContentDocumentLink when deleting file (with ContentDocument)

I have an object 'ClientContract__c' with affiliated files. When adding a file, this changes a technical checkbox field on the parent object. I would like to override this technical field if there are ...
0
votes
1answer
96 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
0answers
24 views

Trying to determine the best way to write a trigger on a file(ContentDocument) which is uploaded and Is realted via COntntDocumentLink to a Case

I am very new to Apex (I wrote one two line trigger and test class successfully) and am trying to figure out this scenario. When a customer or internal user uploads a file related to a Case I need an ...
0
votes
0answers
288 views

Add Upload File button to a custom object

I am working on an assignment where I built a custom object on top of files (ContentVersion, ContentDocumentLink, ContentDocument). Since the customizability of files is limited in Salesforce, we are ...
0
votes
1answer
173 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 ...
32
votes
7answers
12k 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 ...
0
votes
1answer
45 views

content deliveries and public links missing in npsp org

I have created a trigger on contentDocumentLink in my developer org and generating public url for file sharing using ContentDistribution object and when i started moving code to npsp org sandbox, ...
0
votes
2answers
2k 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
1answer
52 views

Link files lead to new custom object

On Lead conversion I also create a new object to which I map several fields of the lead trough processbuilder. I also want to pass the files from the lead to the new custom object. I am trying to do a ...
0
votes
0answers
23 views

Is it possible to open a pdf/word document to a specific page or section with Lighning?

I can generate a preview of a file using e.lightning:openFiles event, but there are no parameters or options that will allow me to open the file up to a specific page or section. Is there anyway this ...
0
votes
0answers
60 views

ContentDocumentLink creation throwing error for guest user

We are getting following error when we try to insert contentdocumentlink to the account using guest user. Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, You ...
5
votes
1answer
76 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 ...