Post to Chatter from Visual Workflow

tennyson

One of the most marvelous aspects of Visual Workflow is the fact that you can hit any API-based object from it. If it’s listed here, you can generally read, create or delete from it (with a few exceptions on protected objects, of course). It’s a surprising amount of power, once you dive into it. Today we’ll look at one of those possibilities: making Chatter posts from Flow. If you’re hip on upcoming events, you’ll know that the Salesforce product team is working on adding a new regular workflow action to post to Chatter (SAFE HARBOR!), but until that day comes, welcome to your one-and-only method of Chatter automation.

Well, you could always code something in Apex. And I suppose you could find something on AppExchange. Ok, it’s not your ONLY solution but it’s a pretty damn good one.

The key to creating a Chatter post is using the object “FeedItem”. “FeedPost” sounds more applicable, but it’s actually counter-intuitive; FeedItem is a newer object that replaced FeedPost (I believe this was done to enable other types of posts, like polls and dashboard components).

You can use the Create Record element, and only a few fields are required for your post.

feeditem

The field “Body” is absolutely necessary. I highly recommend making a Text Template in your Flow and calling it for your Body. If your post is super-short, though, you can just type in what you like.

ParentId is also necessary; this is the Salesforce ID of the record that this Chatter post should be on. You can make it a User ID to post it on their wall, but best practice is to place it on any object that has Chatter Feed turned on. (You may also see a field called RelatedRecordId; this is actually a field only used when attaching Content to a Chatter post!)

LinkUrl and Title are optional; they are used if you wish to post link in your Chatter post. You can type in both of these fields manually, and you can even merge in Flow variables by manually typing in {!variableName}, as shown above.

There are other fields, and some of them may seem necessary, like Type. However, these fields are set to contain default values, and almost always, those default values are what you will want to use, so really the above fields are all you need to worry about.

Other Considerations

  • At this time it is not possible to do @ mentions in your posts. Sad face.
  • Historically, you can use topics, albeit with limitations. If you put a # sign in your post body, the word immediately following it will be marked as a topic. However, it’ll just use one word, so you can’t do topics with spaces in them. I have not tested this in a Spring 14 setup, though, so I am unsure how this will work with the new Topics system.
  • BEWARE THE SPAM. If the Flow that makes a Chatter post is used frequently throughout the day, this will make a LOT of Chatter posts. This can be a good thing, but it can also be an extremely bad thing. If one use uses the Flow 10 times a day, those 10 posts are going to show up in the digests of every user that is following the user. If the follower is also following someone else who is doing the same thing, they now have 20 posts in their digests. If there was only 1 or 2 posts that actually contain something the user needs to see, and they get mixed in with the 10-20 other posts that, frankly, become very samey and ‘boy-who-cried-wolf’ after weeks or months of repetition, the Chatter digests will come to be ignored. I HAVE SEEN THIS FIRSTHAND. Nothing will kill Chatter usage and adoption like Chatter spam.

There you have it! Chatter post automation from Flows! Easy peasy! Now, because there has not been nearly enough levity in this blog post… narwhals.

Advertisements

4 comments on “Post to Chatter from Visual Workflow

  1. In regards to the Text Template you mention above, is it possible to add line breaks? I’ve tried adding

    Everytime the breaks are stripped out and I’m left with a blob of text. Also, I’m trying to use this with the SendEmail Apex class provided by Flow Sample Pack.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s