0 votes
1 view
in Salesforce by (11.9k points)

If you navigate to account/contact/custom object we do have a related list "related content" (if the content is enabled and the related list is added to page layout).

My question is where 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.

UPDATE

Tried to create a link to show up in "related content" section of the 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');

** USE CASE **

The use case is to allow user to attach content right from object detail page for eg say Account will have button say Attach Content, this will bring upload content page, once uploaded (i will create contentversion records - this is happening perfectly, no errors) and then I need to relate the uploaded content to account (from which request originated) ie create "related content" records (here I'm facing difficulty, trying to create contentdocumentlink records but its erroring out).

The use case is just one click to attach content to account or opportunity instead of long current process was user goes to content, uploads there first and then comes back to account/opty and searches content again, and then attaches it to account/contact.

1 Answer

0 votes
by (31.6k points)

So the content is stored in ContentDocument object whereas the links are stored in the ContentDocumentLink table.

 http://workbench.developerforce.com is really useful for figuring out these kinds of relationships.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...