Find your content:

Search form

You are here

Missing Organization Feature: Chatter

 
Share

We created a package that uses chatter functionality. One of our users is not using chatter and disabled in their org so our package is throwing an error "Missing Organization Feature: Chatter". User is not willing to enable chatter.

Is there a way that we can write some condition if chatter is enabled do this and if not do this.

I am already checking id the chatter is enabled using the below snippet

Schema.DescribeSObjectResult R = CSTest__c.SObjectType.getDescribe();
            return R.isFeedEnabled();

In visualforce page

<chatter:feedWithFollowers entityId="{!testIdChatter}" id="chatterId" />

Is there away that we can write the functionality if the chatter is not enabled do some other stuff.


Attribution to: Ugesh Gali

Possible Suggestion/Solution #1

Unfortunately this is a hard problem without many tried and tested solutions!

Determining if chatter is enabled:

Boolean isChatterEnabled = true;
try {Type.forName('FeedItem');}
catch (System.NoAccessException e) {isChatterEnabled = false;}

System.debug(isChatterEnabled);
//gives true/false as appropriate

Possible prevention of feature dependency in Visualforce:

<!-- try using a Dynamic Component in the VF page -->
<apex:dynamicComponent componentValue="{!DynamicChatter}" />

//this is all a wild guess
public ApexPages.Component getDynamicChatter() {
    ApexPages.Component cmp;
    if (isChatterEnabled) {
        ApexPages.Component cmp = Type.forName('Component.Apex.Chatter').newInstance();
        cmp.put('entityId', testIdChatter);
        cmp.put('id', 'chatterId');
    }
    return cmp;
}

Prevention of feature dependency when performing DML using dynamic types for inserts:

public 
if (isChatterEnabled) {
    SObject feedItem = Type.forName('FeedItem');
    feedItem.put('ParentId', UserInfo.getUserId());
    feedItem.put('Body', 'Check out my dependency free chatter post!');
    insert feedItem;
}

Prevention of feature dependency when querying, using dynamic SOQL:

if (isChatterEnabled) {
    Id userId = UserInfo.getUserId();
    List<SObject> myPosts = Database.query('SELECT Body FROM FeedItem WHERE Id = :userId');
}

Attribution to: bigassforce

Possible Suggestion/Solution #2

You should be able to use the connect api for this. There is a method getSettings that returns which features are enabled

ConnectApi.Organization.getSettings().features.chatter

Attribution to: jwolf

Possible Suggestion/Solution #3

This specific situation is addressed in the documentation for ISV apps. It references the error and where you must do a specific try-catch to get around it. I think the document is called ISVForce documentation. It is the one that also has instructions for LMA and best practices for working with managed packages.


Attribution to: DavidSchach
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/32144

My Block Status

My Block Content