[SalesForce] How to make calls related to a case display in its Chatter feed

I am using the Service Console in Lightning Experience, and using the Chatter Feed component on the Case layout to display updates to the Case.

If I use the "Log a Call" Quick Action from the Chatter publisher, these calls are displayed in the Chatter feed. This is the desired behaviour.

However, if I insert a Log a Call record related to the Case any other way – e.g. using the Developer Console, or my CTI system's custom components – the call does not display in the feed.

If I query the record, it looks exactly the same as the record that is created with the Quick Action. It just seems that the Chatter post is never made in this situation.

I have checked my Feed Tracking settings:

  • Task has Enable Feed Tracking and Subject checked
  • Case has All Related Objects checked

How can I enable calls created with a custom component (part of a CTI system) to display in the case feed?

Best Answer

You can do this in Apex if you fill out all the right fields.

Task t = new task(
    WhatId = someCase.Id, // Case to log against
    CallObject = 'Call Center To Log To', // Gotten from CallCenter object
    WhoId = someContact.Id,
    Subject = 'Outbound Call', // Can be whatever you want
    CallDurationInSeconds = 100,
    ActivityDate = Date.Today(),
    CallType = 'Outbound', // Inbound, Outbound, or Internal
    Description = 'Notes about the call here.',
    Status = 'Completed', // Make the call closed
    TaskSubType = 'Call', // To log a call
    Priority = 'High' // Any legal value okay here
);
insert t;

No need to insert a FeedItem, it'll work just like magic.

Despite what the documentation appears to say, this definitely works in my org. This also works in the REST API (and presumably others).