How-To: Create a Chatter Post in Salesforce and Include a File


Join our newsletter!

Receive the latest data collection news in your inbox.

[bctt tweet=”Learn how to use FormAssembly to create a #Salesforce #Chatter post w/ a file included” username=”FormAssembly”]

Please note: The FormAssembly file upload size limit is 35MB per response. Please view this FormAssembly help article for more information on Salesforce and FormAssembly file upload size limits.

Does your organization use Chatter? You can use FormAssembly to post directly to any Chatter feed.

You can even include a file, so your org can view the file right in Chatter. No extra steps necessary.

Chatter posts are named FeedItem in the Salesforce API. If Chatter is enabled for your Salesforce org, you’ll see the FeedItem object listed in the Salesforce Connector setup page, like so:

You can create and attach a Chatter post to any Salesforce record (for example, Contact, Case, or Opportunity).

A FeedItem object requires a Parent ID and some content, which can come from data submitted through the form, or which you can define at setup time.

If you’d like the Chatter post to include a file, you’ll need two extra steps: uploading the file to Salesforce and then associating it to the post.

To upload the file, you’ll create a ContentVersion object:

You’ll note a few things here:

  1. ContentDocument ID shows as a required field — do not map anything to it. Salesforce will do that for you when you create the ContentVersion.
  2. Content Origin is set to “H”, relating it to Chatter
  3. Content Location is set to “S”, meaning that the file is natively in Salesforce.
  4. The First Publish Location ID is set to a User record — this can be changed to any other object except the FeedItem. We’ll get to that in a second.
  5. Version Data and Path on Client are both mapped to the actual file upload field in your form.

Now that we have the file in Salesforce, we’ll associate it to the Chatter post we created in step 1. This is done with a FeedAttachment junction object:

A few simple steps to map: the Feed Attachment Type as “Content” and then relating the record IDs of the objects we made in steps 1 and 2 in our connector.

That’s all you need to set up. Your Chatter posts can be associated with any record in Salesforce. For instance, they can show in a Lead’s Chatter feed, like below:

If you’ve got questions, leave a comment, email us, or tweet @FormAssembly.

For more Salesforce tutorials, check out our FormAssembly + Salesforce tutorial eBook at the link below.

Don’t just collect data
— leverage it