Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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');
}
share|improve this answer
    
I am keeping the condition where ever we are querying feed object and if chatter is enabled then only do this. I don't where the dependency got introduced and need to check line by line. –  Ugesh Gali Apr 8 at 9:29
    
I raised support ticket to salesforce Their Answer is "As mentioned in the error message, we cannot install packages which include chatter functionality in orgs which do not have chatter enabled. Please let me know your further queries on this case." –  Ugesh Gali Apr 8 at 9:50
    
@UgeshGali totally worth educating your customer on the benefits of Chatter, if your app requires it. It's an ever-growing cost trying to tip-toe around the feature dependency for the sake of these holdouts ;-) –  bigassforce Apr 8 at 10:25

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.