4

We have a managed package that makes use of chatter feed object in one of our apex class. We would like to know if it is possible to develop a managed package that leverages Chatter but can be installed in organisations that don't have chatter enabled?

In case if there is no such standard way to achieve this, we have thought of a work around. It is to release a later version with all mention of chatter stripped out of apex. Then later again putting the chatter code back to our apex.

We would like to know if there are chances of any problem with this work around. Or if there are any better work arounds?

Thanks, Rupali

1 Answer 1

4

In order to avoid a Chatter package dependency you need to

  • Ensure you do not Enable Feeds on any of custom objects
  • Ensure you do not explicitly reference the Chatter objects or Connect API, such as Feeds
  • Ensure you do not having any Apex Triggers on Chatter objects in your package

This means that subscriber admins will need to post install enable feeds on your objects and that your code must utilise Dynamic Apex to query and manipulate Chatter objects. For example to insert a Feeds record without making specific reference to it, somethnig like the following would be needed.

List<SObject> feedItems = new List<SObject>();
Schema.SobjectType feedItemSObjectType = mapGlobalDescribe.get('FeedItem');
SObject feedItem = feedItemSObjectType.newSObject();
feedItem.put('Body','My message');
feedItem.put('ParentId',myRecordId);
feedItems.add(feedItem);
insert feedItems;

NOTE: Not sure if this applies to you, but it is possible to add Apex Triggers to some Chatter objects, these cannot leverage Dynamic Apex. You would either have to deploy these as an extension package to your main package. Or consider exposing the logic from your core package as global methods and then deploying some smaller triggers in the subscriber org.

Finally always click the Show Dependencies button before doing your Upload to confirm.

ISV Force Guide

The following topics from the must read ISV Force guide cover supporting different editions of Salesforce, the same advice applies to supporting different features.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .