7

After enabling Chatter Answers, I now have a trigger called chatter_answers_question_escalation_to_case_trigger. The trigger fails test coverage at 35%. What can I do about this?

enter image description here

2 Answers 2

1

I believe this is a known issue. One of the the possible workarounds is to delete the trigger - even that's a tricky process as you have to delete delete everything at one time. Use the force.com IDE to delete all related classes and the trigger at once. There are some threads like this and this where this issue has been reported earlier.

2
  • 1
    Wouldn't this option only work if you don't plan on using Chatter Answers after enabling (considering you cannot successfully disable it)? I'm just covering bases here for others reading. I don't use chatter answers, but I'm stuck with it since I enabled it already. I'll try this out. I would love to get rid of the trigger. I'll follow up.
    – fourq
    Dec 28, 2013 at 20:09
  • 2
    I removed this trigger, and its accompanying test class. Now I have 4 test classes > 80% and near 50 at 100% and I'm still at 65% org code coverage. I'm going to submit a case to sfdc.
    – fourq
    Dec 28, 2013 at 20:24
0

For those who want a quick fix, edit the trigger to be on one line. It's completely not advisable, but it gets you out of the dog house.

trigger chatter_answers_question_escalation_to_case_trigger on Question (after update) 
{
    for (Question q: Trigger.new) 
    { 
        try 
        { 
            if (q.Priority == 'high' && (q.Cases == null || q.Cases.size() == 0) && Trigger.oldMap.get(q.id).Priority != 'high') 
            { 
                q = [select Id, Title, Body, CommunityId, createdById, createdBy.AccountId, createdBy.ContactId from Question where Id = :q.Id]; 
                Case newCase = new Case(Origin='Chatter Answers', OwnerId=q.CreatedById, QuestionId=q.Id, CommunityId=q.CommunityId, Subject=q.Title, Description = (q.Body == null? null: q.Body.stripHtmlTags()), AccountId=q.CreatedBy.AccountId, ContactId=q.CreatedBy.ContactId); 
                insert newCase; 
            } 
        } 
        catch (Exception e) 
        { 
            String subjectText = 'Case Escalation exception in site ' + Site.getName(); 
            String bodyText = 'Case Escalation on Question having ID: ' + q.Id + ' has failed with the following message: ' + e.getMessage() + '\n\nStacktrace: ' + e.getStacktraceString();  
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
            String[] toAddresses = new String[] { Site.getAdminEmail() }; 
            mail.setReplyTo('[email protected]'); 
            mail.setSenderDisplayName('Salesforce Chatter Answers User'); 
            mail.setToAddresses(toAddresses); 
            mail.setSubject(subjectText); mail.setPlainTextBody(bodyText); 
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
        }
    }
}

You must log in to answer this question.

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