function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Autofollow Topic Trigger

Hi everyone.

Not sure if I am in the right place(New UI look is really messing with me) but I have an chatter related trigger question.  

I was handed some requirements to write a trigger that would do the following:

Anytime a chatter post is made on a CASE that contains the string "#Outage" 
the trigger needs to automatically force all members of a specific chatter group to follow the case record that the post was made in

I havent had to write any code relating to chatter so I am not really sure how this would work.  

The concept seems really easy, would the new TOPIC TRIGGER feature work for this?

Phillip SouthernPhillip Southern
Hi, I dont have a snippet on hand to provide....but I know there have been a few demos and sessions at dreamforce regarding this.  I believe this is the one I saw while there:

Yes, the #Outage hashtag will be converted to a Topic, so you can create a trigger on TopicAssignment. You'll have to check whether the EntityId property of the TopicAssignment is a FeedItem ID (starts with "0D5"), and if so, you'll have to do another query to get the ParentId of the FeedItem. You need the ParentId to determine whether or not the post was made on a Case, and then to have everyone in the group follow it.

It might be a bit simpler to create a trigger on the FeedItem (and possibly FeedComment) objects and just do a string search for "#Outage" in the body. That way, you'll be able to access the ParentId directly. If the post was made on a case, the ParentId will start with "500", which is the key prefix for the case object.

Let us know if you have any problems getting the members from the group and having them follow the case record.