Skip to main content
I know it's possible to use the Bulk API to upload files to the Attachment object on records, but how would you bulk upload to Chatter Feeds on Contacts?

 

We have a load of attachments in our current system we need to upload to SF and attach to records, and then also search them, but it's just not possible to search attachment bodies using SOSL.

 

I've been able to search the ContentVersion object using SOSL, but not Attachment.

 

Can anyone shed some light on this for me? I need documents to be uploaded through a batch process to the Chatter (ContactFeed) on Contacts.

 

Thanks in advance.
1 answer
  1. Sep 22, 3:22 PM

    Hi Paul,

    Because you need to make those files searchable via SOSL, leveraging Salesforce Files (ContentDocument and ContentVersion) is definitely the right approach compared to legacy attachments. However, bulk-loading files directly into the ContactFeed (or via FeedItem / FeedAttachment) through a standard batch process requires linking the Content Document to the record feed correctly. 

     

    Here is how you can set up a bulk upload and feed attachment process:

    1.Bulk Load Files via ContentVersion:Content Version Upload. 

    Use Data Loader or the Bulk API to insert your documents into the ContentVersion object. This creates the underlying file records in Salesforce and makes their searchable text bodies fully indexable for SOSL queries. 

    Verification:

    Querying ContentVersion via SOQL confirms your files have successfully uploaded with valid Title and VersionData fields. 

     

    2.Create FeedItem and ContentDocumentLink Records:Feed Attachment Linking. 

    To attach those files to the specific Contact's Chatter feed, you need to create a ContentDocumentLink record mapping the ContentDocumentId to the ContactId with ShareType = 'V' (Viewer) and Visibility = 'AllUsers'. Then, insert a corresponding FeedItem record with Type = 'ContentPost' referencing the file to display it directly in the contact's feed. 

     

    Verification: Checking a contact record in Salesforce displays the uploaded document rendered cleanly in their Chatter feed.

0/9000