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
bob17bob17 

Does chatter support require customer to have chatter enabled?

We have a managed package that could have added value if we added some chartter functionality to it but there is no way we are going to do this if the it then required Chatter be enabled before our package can be installed.  I have seem some speculation on the boards re use of dynamic DML to create posts and still not require chatter be enabled.  Obviouly app can't create posts unles the feature is enabled but I see how to dynamically determine that but I was hoping for a definitive Can / Can Not be done from someone at Salesforce or someone who has actually done it.

 

Thanks in advance.

Best Answer chosen by Admin (Salesforce Developers) 
bob17bob17

When in doubt just try it out so I built a very simple managed package that can creates a Chatter Post on an Opportunity object.  I was able to do so with dynamic DML in a manner that allows it to be installed into an org that does not have Chatter enabled.  A snippet of the code that checks to see if Chatter is enabled and dynamically creates and inserts a FeedPost object is as follows:

 

 

Schema.DescribeSObjectResult r = opportunity.sObjectType.getDescribe();		
if(r.IsFeedEnabled())
{
     SObjectType token = Schema.getGlobalDescribe().get('FeedPost');
     SObject objPost = token.newSObject();
     objPost.put('ParentId', m_oppty.Id); // m_oppty is an instance of an Opportunity object
     objPost.put('Body', 'your chatter post text here');
     insert objPost;	
}