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

Not able to access ContentDocumentLink on Site VF page's Controller(without sharing)

SOQL: [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = {{reocrdID}}] OR SELECT Id, (SELECT ContentDocumentId FROM ContentDocumentLinks) FROM {{sObjectAPIName}} Where id = {{...
sfdcnoob's user avatar
  • 101
2 votes
1 answer
920 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 ...
Manoj kumar's user avatar
10 votes
1 answer
10k 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 ...
user7100889's user avatar
0 votes
1 answer
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 ...
Mark McGill's user avatar
1 vote
2 answers
5k views

Cannot update contentDocumentId in contentDocumentLink

I am sharing a file with a task by creating ContentDocumentLink. The LinkedEntityId points to the task record. Now, if a certain update happens to a parent record then i am trying to update only ...
lambad's user avatar
  • 385
3 votes
1 answer
17k views

How to query ContentDocumentLink in SOQL and then upsert records in Data Loader

When querying ContentDocumentLink in SOQL using the following query, an error is thrown. Goal: We are attempting to get a spreadsheet of the data so we can update IsDeleted flag with TRUE on entries ...
WrittenInCode's user avatar
0 votes
1 answer
140 views

Replace Content Notes in bulk or replace ContentDocumentLink

We are looking for a way to either replace Content Notes in bulk (the wrong .txt files were linked, however the metadata is correct), or replace the ContentDocumentLinkIds while removing the old ones. ...
WrittenInCode's user avatar
0 votes
2 answers
1k views

Make the test work: File insert, check this File

This code is a controller for my VF Page. It inserts ContentVersion and ContentDocumentLink. After that a candidate field Photo__c take a ContentVersion.Id value. How to check it correctly? Now ...
MichaelLev19's user avatar
1 vote
0 answers
157 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 ...
Mike Raven's user avatar
  • 2,133
7 votes
1 answer
4k 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> ...
Robs's user avatar
  • 9,177
2 votes
2 answers
2k 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 &...
Saiball Roy's user avatar
3 votes
1 answer
3k 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 ...
sanket kumar's user avatar
4 votes
1 answer
511 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 ...
Keith C's user avatar
  • 135k
1 vote
1 answer
488 views

Content objects not returned in queries run by public guest/site user

When associating a Salesforce File to an object in the UI, the associated ContentDocumentLink and ContentVersion records are not returned when a public guest/site user queries for them. An internal ...
Will Johnston's user avatar
2 votes
1 answer
2k 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 ...
Keith C's user avatar
  • 135k
1 vote
1 answer
2k views

How to import contentversion records(csv file) using dataloader

i have three records in csv file and three pdf files. how can i import these content version records to sandbox. i tried, but when i am uploading csv file using dataloader, i got Required fields are ...
Sfdcprgmr's user avatar
  • 405
12 votes
1 answer
2k 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 ...
Keith C's user avatar
  • 135k
1 vote
0 answers
208 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?
manjula's user avatar
  • 11
4 votes
1 answer
2k 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 ...
Dinesh Wickramasinghe's user avatar
5 votes
0 answers
924 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 ...
salesForceNoob's user avatar
10 votes
1 answer
7k 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@...
Uwe Heim's user avatar
  • 28.3k
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( ...
Uwe Heim's user avatar
  • 28.3k
4 votes
1 answer
2k 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 ...
LearningDash's user avatar
0 votes
2 answers
9k 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 ...
LearningDash's user avatar
3 votes
0 answers
3k 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 ...
The Evil Greebo's user avatar
3 votes
2 answers
3k 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 ...
ZAR's user avatar
  • 2,013
0 votes
1 answer
413 views

Query to retrieve certain files from Product2

I have the following use case: A web shop (Java) retrieving products from SF using the SOAP API. Attached "Files" are retrieved and displayed by selecting them through ContentDocumentLinks related to ...
Stijn's user avatar
  • 409
1 vote
0 answers
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 ...
Blanca PJ's user avatar
-1 votes
1 answer
1k views

Add a version of file to a existing file version(ContentVersion)

I am trying to attach a versions of file with content Versions to a existing content version, i don't know how to do that... actually i arrive to insert file but some duplicate file is present and i ...
Merveille Balin's user avatar
2 votes
1 answer
2k 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 ...
David Reed's user avatar
  • 92.1k
0 votes
0 answers
657 views

Convert legacy attachments into the files

I need help to convert legacy attachments to files with lastmodifieddate of file is equal to created date of attachments by using apex code. I need to do it for all objects on which attachments are ...
saurabh gupta's user avatar
0 votes
1 answer
2k views

File SOQL query

I need to search for Partner Accounts that don't have a Partner Agreement attached in the Files section. To find that, I believe the best way is to get a list of all Files attached to the Accounts ...
Priscila's user avatar
1 vote
0 answers
422 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 ...
Keval Suchak's user avatar
2 votes
1 answer
2k views

Public guest user can't access ContentDocuments

I have a site with a Visualforce page that requires access to ContentDocuments linked to an Opportunity. My problem is that i can only see, as a public guest user, content documents that are uploaded ...
user37586's user avatar
  • 660
0 votes
0 answers
954 views

Understanding ContentDocumentLink object API

As per documentation, I am trying to understand the following point - "For organizations with Communities enabled, a document can only be shared with users and groups that are a part of the community ...
LakhanP's user avatar
  • 771
0 votes
1 answer
582 views

Prevent deletion of ContentNote

Is there anyway to prevent a user from deleting a New Note, based on the status of the Opportunity that the contentnote is linked to? The requirement is that I have a datetime field that is set, once ...
sfnoob's user avatar
  • 55
1 vote
2 answers
4k 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 ...
Yogesh Bhosale's user avatar
1 vote
0 answers
697 views

Internal Salesforce.com Error while executing batch class

I want to create a batch class for the ContentdDocumentLink. I am getting records in the querylocator. But the execute() method is not working. In the debug logs also I am not able to trace any ...
Kumar Saurav's user avatar
1 vote
3 answers
15k 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 ...
user49158's user avatar
3 votes
1 answer
3k 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 ...
Uwe Heim's user avatar
  • 28.3k
0 votes
0 answers
613 views

How do I share files wtih a chatter group automatically via a trigger?

When I upload a file via the chatter feed I want that the file is shared with a particular group in my org with contributor status. I think it must be a trigger on the ContentDocumentLink and a after ...
Bretzelman's user avatar
3 votes
2 answers
4k 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 ...
Prakash Chandra's user avatar
0 votes
0 answers
280 views

Why ContentDocumentLink reference user?

I need to add copy of Service Report when it is created in Service Appointment to its parent. To do so I tried to create trigger on ContentDocumentLink. My idea was to get this ContentDocumentLink, ...
user2452483's user avatar
4 votes
0 answers
1k 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....
sfdc's user avatar
  • 13.6k
0 votes
1 answer
254 views

Batch Apex creating Multiple contentdocumentlinks when trying to "convert" tasks to notes...

I am trying to look at all tasks for a specific time frame, then create a note and set the LinkedEntityId to the whatid or whoid. This code creates the content note, 1 for each task. But then created ...
Merry Stambaugh's user avatar
2 votes
0 answers
554 views

Cannot Query ContentDocumentLink as a Portal user

I have a situation where I am trying to retrieve documents which were generated by DrawLoop and added to SFDC as Files. As the System Admin user, I can query for this data using the following query: ...
Scott Cromie's user avatar
0 votes
0 answers
672 views

How to use current record Id (In after insert trigger) to save it in some different object?

Please find my scenario below I will talk in generic words so that the objects name should not confuse someone. I have written after insert trigger on an object and obviously, I am getting the Id of ...
Kapil Kaushik's user avatar
6 votes
1 answer
8k 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 ...
tim shores's user avatar
0 votes
1 answer
228 views

Data load to ContentNote Object using any tool (Informatica Cloud or DataLoader)

I found the below link (another question) - this does not seem to be a correct answer and am urgently looking for a solution for the same. ContentNote with related Object After loading the ...
shobhan kumar's user avatar
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 ...
sfdc's user avatar
  • 13.6k