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
34
votes
7answers
14k 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 ...
8
votes
1answer
498 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 ...
7
votes
1answer
2k views

How to Upload a File to a specific Library Folder using Apex?

I am trying to save a Visualforce page as a PDF file to a Library folder in our Salesforce org. I have been unable to figure out how to save this new PDF file to a specific Library folder. I tried ...
7
votes
1answer
1k 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@...
6
votes
1answer
135 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 ...
6
votes
0answers
3k 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 business ...
5
votes
3answers
2k 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 ...
4
votes
1answer
954 views

How to prevent duplicate File (ContentDocument) if the same file is uploaded at multiple records?

This is a day-to-day use case: Assume there are many Opportunities on an Org. Now Sales-Reps are uploading some auxiliary information as Files in Lightning using the standard related list and there ...
4
votes
1answer
267 views

Why is this ContentNote trigger receiving 1 record at a time even though multiple records are being inserted?

I am seeing a ContentNote trigger called on individual rows even though a bulk insert is done. A stripped down version follows. The debug log output demonstrates that 3 ContentNote objects are ...
4
votes
1answer
526 views

Generate a Public Accessible link from ContentDocument

My Client wants to upload Image files from Account and generate a link for this image file and save it in a custom field on Account. This link should be Public Accessible (access from outside without ...
4
votes
5answers
2k views

Document: You don't have permission to share this file

I am trying to upload a file from salesforce sites into Files and then relate it with a record using VF page. i am able to upload the file and while creating a ContentDocumentLink i am getting this ...
4
votes
0answers
443 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 ...
4
votes
2answers
512 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[]{'heim@elastify.eu'} ); m.setSubject( 'test' ); m.setHtmlBody( ...
4
votes
0answers
552 views

USING SCOPE Everything not working

I wrote a trigger on ContentDocumentlink to get a count of number of files uploaded against Service_Request__c (Custom Object) record.It works fine for new files are uploaded on Service Request record....
3
votes
2answers
1k views

SOQL ContentDocument: Ids not returning

A handful of our users have created notes on contact and opportunity objects that we are trying to port over. They are currently saved as ContentDocuments - but I also want to pull what objects the ...
3
votes
2answers
897 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 ...
3
votes
0answers
62 views

SOQL query in Trigger returns no results but returns a row in Developer Console

I have the following code snippet in a Helper class that's being called by an After Insert trigger (modified to demonstrate my objective): Set<Id> reuseIds = new Set<Id>(); reuseIds.add('...
3
votes
1answer
67 views

Why can't I Insert ContentDocumentLink linking to Community user?

I have written a trigger class on content document link to create a task whenever a community user creates a task on a case. Currently, the trigger works perfectly when attaching a case through the UI,...
2
votes
2answers
414 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 ...
2
votes
1answer
830 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
1answer
37 views

Why Blob equals doesn't work if one of the Blobs is retrieved from ContentDocument?

In brief, I can't test the value stored in a ContentDocument. Even if the value of the two Blobs is the exact same, equals would return false. Do someone know the reason? Here's a unit test to check ...
2
votes
1answer
350 views

“Unable to create/update fields: VersionData” error when updating a ContentNote from Apex

I have some Apex code that inserts a ContentNote and the corresponding ContentDocumentLink. This works fine and the data can be viewed through the normal Salesforce UI. But some further code that ...
2
votes
1answer
32 views

Perplexing ContentDocumentLink SOQL issue

I have the following code: // Note: cdlToDos == Map<Id, Set<decimal>> System.debug(cdlToDos); List<ContentDocumentLink> cdlList = [ SELECT Id, ContentDocumentId, LinkedEntityId ...
2
votes
2answers
279 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
1answer
400 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 ...
2
votes
0answers
21 views

How to determine if the user has enough permissions to Share ContentDocument to sObject

I have a situation that seems to be consistent with the top comments here: https://success.salesforce.com/ideaview?id=087300000006n4GAAQ Specifically, i have a Content Workspace aka Content Library, ...
2
votes
0answers
28 views

While adding new contentDocumentLink Contentdocuments lastmodifieddate is getting changed. How we can stop that

I am migrating attachment records to contentVersion. I am also updating created and lastmodified date of new contentversion records from Attachment record. It is getting updated fine. But when I am ...
2
votes
0answers
60 views

Site Guest Users Cannot Insert or Query ContentDocument or ContentDocumentLink objects

Update (31/01/20) As per the newly created Knowledge Article, Salesforce has stated that in order to not receive an error while Inserting/Querying a ContentNote/ContentDocument/ContentDocumentLink as ...
2
votes
0answers
665 views

ContentDocumentLink - Can't set Visibility:InternalUsers when linking to case in specific sandbox

I have to push about 40,000 files into Salesforce as case files for a go live cutover. I have a process which creates a ContentVersion and then a ContentDocumentLink. In one sandbox, the files are ...
2
votes
2answers
105 views

how to select a ContentDocumentLink via SOAP API from .NET?

We are having trouble getting a "ContentDocumentLink" object back to a .net client via an authenticated API call. A similar call works fine for records from the "Attachment" object. The credentials ...
1
vote
3answers
1k 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
3answers
5k views

ContentDocumentLink insertion fails

I want to share all records with admin user using next trigger: trigger ContentVersionTrigger on ContentVersion (after insert) { system.debug('sdfsdf' + Trigger.new); for (ContentVersion ...
1
vote
1answer
47 views

Find all notes which are not related to anything

We imported numerous notes into Salesforce and we were able to connect most of them to their corresponding objects with ContentDocumentLink. However, a few of need to be manually connected. So how can ...
1
vote
1answer
928 views

ContentDocumentID is not available just after ContentVersion getting inserted But available after soql query

I am inserting ContentVersion as following:- String yourFiles = 'Lets assume this is your binary string of the files'; ContentVersion conVer = new ContentVersion(); conVer.ContentLocation = 'S'; // S ...
1
vote
1answer
812 views

Scheduled Data Export: how to obtain ContentVersion linking data

I've used the Data Export feature to pull down ContentVersion data for Files and (Enhanced) Notes from a Salesforce org that's being migrated into a different org. I've been unable to locate the ...
1
vote
2answers
2k views

LinkedEntityid is the user incorrectly coming in ContentDocumentLink trigger

I am creating a trigger on ContentDocumentLink and I am attaching a file via upload file option in related list to a record. In trigger(after insert), the linkEntityId is generated as user id but I ...
1
vote
1answer
127 views

ContentDocumentLink fires trigger multiple times on list insertion [duplicate]

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 ...
1
vote
1answer
317 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 ...
1
vote
1answer
275 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 ...
1
vote
0answers
16 views

Email sent when inserting ContentDocumentLink record

I have noticed that when using Apex to programmatically insert a list of ContentDocumentLink records that the users specified in the LinkedEntityId are receiving an email notifying them that the ...
1
vote
1answer
434 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
0answers
120 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 ...
1
vote
0answers
34 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 ...
1
vote
0answers
313 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; ...
1
vote
1answer
210 views

How to query contentversion to Email Message

We have integrated Salesfroce and our Support Page, and I have to send emailmessage via rest api along with attachment lies within the email, but I don't find a relateionship between Contentversion ...
1
vote
0answers
75 views

Can't share Content Document with Salesforce object

I have a Salesforce org with Salesforce CRM Content enabled but I can't share Content Document with Salesforce object. There are no Related Content related list in layout and I also can't create the ...
1
vote
2answers
731 views

Unable to extract bulk ContentVersion and ContentDocumentLink data using Salesforce API

Use Case: Transfer existing (and OOTB) Files that are linked with couple of custom objects (CO 1 & 2) to another Custom object (CO X)? The new custom object (CO X) has look up fields for CO 1 &...
1
vote
0answers
108 views

Translate IsPrivate check into Enhanced Notes

I am migrating notes into Enhanced Notes, How do I move the IsPrivate(Checkbox on Notes) values into Enhanced Notes? If the IsPrivate Checkbox is checked on Notes, how can I do this on EnhancedNotes?
1
vote
0answers
1k views

ContentVersion trigger event AfterInsert -> Insert ContentDocumentLink -> FIELD_INTEGRITY_EXCEPTION

We need to get a solution / workaround to insert in ContentDocumentLink several links when a File that has just been inserted (ContentVersion) and sibling records of other Custom Object. A third ...
1
vote
0answers
252 views

How to show error msg in ContentNote?

I want to show error msg whenever notes get created without attaching to any records. As trigger on ContentNote is not available I've written Trigger on ContentDocumentLink, but I am not able to show ...