You need to sign in to do that
Don't have an account?
Opster
Check in APEX if Chatter is enabled for current Org?
Does anyone know how I can check in APEX IF Chatter is enabled for the current Org?
I need to check either in a Visualforce page or in an Apex Class and display chatter if it is, and not display it if it is not enabled.
thanks
I have yet to try and check the User field with current status because a user can clear their status, but I know this works and has been tested. Apparently, if chatter is disabled it is no longer visible to the Org/User which is why this simple code snippet works.
All Answers
From Winter 11, you can check
. Here is an example from the release notes:
Can I do a check without doing an INSERT? For example below:
the params are not needed in that code snippet.
It looks like querying is not supported for FeedPost. Too bad.
So there is no way to just check the features the org supports directly without inserting and catching the error?
As of Spring 11, you should not be working with FeedPost, rather you could query FeedItem if you limit with an id or query an EntityFeed, but you question about query vs. insert should work fine.
I am finding that this is not a good solution since if the Org does not have chatter enabled the FeedPost object is not available at all, and I cannot save the code to the org.
Any other ideas?
Could you do a describe on the User object to see if the CurrentStatus field exists?
you can try describe s-object on User object and check does there any fields exist like CurrentStatus ?
Thanks,
Bala
I have yet to try and check the User field with current status because a user can clear their status, but I know this works and has been tested. Apparently, if chatter is disabled it is no longer visible to the Org/User which is why this simple code snippet works.
Just want to add this important note, which indicates that this approach will not work with a managed package:
"If thegetGlobalDescribemethod is called from an installed managed package, it returns sObject names and tokens for Chatter sObjects, such as NewsFeed and UserProfileFeed, even if Chatter is not enabled in the installing organization. This is not true if thegetGlobalDescribemethod is called from a class not within an installed managed package."
From: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_describe_objects_understanding.htm
Schema.SObjectType.User.isFeedEnabled();