1

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 and the emailmessage.

I there a way to query contendocumentlink contendocument and contentvesion all in one??

0

So, whenever you Insert ContentVersion, a link for ContentDocument is created, You can query that out.

One you have ContentDocumentId you can create a content document link and attach it to concerned EmailMessage

ContentVersion cv = [Select Id, ContentDocumentId from ContentVersion where Id='YOUR_INSERTED_CONTENT_VERSIONID_FROM_REST_API'];

Then create your contentDocumentLink by

ContentDocumentLink cl = new ContentDocumentLink();
cl.ContentDocumentId = cv.ContentDocumentId;
cl.LinkedEntityId = 'YOUR_INSERTED_EMAIL_MESSAGE_ID;
cl.ShareType = 'V';
cl.Visibility = 'AllUsers';
insert cl;

This is the Pseudo code, but can be implemented in rest:

Src https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentversion.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.