+ Start a Discussion
Chirag MehtaChirag Mehta 

"Related Content" stored in which object / How to create "Related Content" records from Apex

If you navigate to account/contact/custom object we do have a related list "related content" (if content is enabled and related list is added to page layout).  My question is were are these "related content" records stored? in which object?
Using apex I'm able to upload file to content version, but not able to create or find the object which stores the "related content" information.
Chirag MehtaChirag Mehta

Tried to create a link to show up in "related content" section of account, but no success. Got error " Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for this type of entity through the api: [LinkedEntityId]" Any idea?

 

ContentVersion cv = new ContentVersion(
            versionData = EncodingUtil.Base64Decode(base64BlobValue),
            Title = fileName,
            PathOnClient = '/'+fileName,
            FirstPublishLocationId = '058900000009KcL'
        );
        insert cv;

        //fetch ContentDocumentId
        cv = [Select Id,ContentDocumentId from ContentVersion where Id = :cv.Id];

        insert new ContentDocumentLink(LinkedEntityId=parentId,ContentDocumentId=cv.ContentDocumentId,ShareType='V');

 

Rahul_sgRahul_sg

is it ContentDocumentLink ?....

 

Also, the name of the related list is 

Content Deliveries right?

Chirag MehtaChirag Mehta

@Rahul_sg : Yes its ContentDocumentLink and the related list name is "Related Content" 

James GJames G

Hi guys, was there ever a resolution for this issue?  I am encountering the same error and have turned on Chatter Feed for the custom object as well.  I can relate a User record without problems but not my custom object.  Any clues?  Thanks!

Balkishan Kachawa 9Balkishan Kachawa 9
I am having the same problem, can anyone help?