1

When I do to Log a Call on a Case it creates a Task record in the Case activity timeline and a entry in the Case feed.

But when I create a Task record against a Case using Apex, but it's not appearing in the Case feed.

How can I create a Task that's related to a Case which also appears in the Case feed?

2
  • Are you setting the WhatId to the current Case SFID? Is this for Salesforce Classic and you're asking about the Chatter feed? Commented May 4, 2019 at 19:14
  • 1
    @BrianMiller it's for Lightning. I am setting the whatId to the case.Id
    – Robs
    Commented May 4, 2019 at 19:29

1 Answer 1

2

Caveat: I can't reproduce the exact behavior you're describing; I do get feed posts in most cases, pun intended. Here's what I found.

There's some specialized behavior around FeedItem posts linked to Case records (see under Type):

ActivityEvent—indirectly generated event when a user or the API adds a Task associated with a feed-enabled parent record (excluding email tasks on cases). Also occurs when a user or the API adds or updates a Task or Event associated with a case record (excluding email and call logging).

For a recurring Task with CaseFeed disabled, one event is generated for the series only. For a recurring Task with CaseFeed enabled, events are generated for the series and each occurrence.

I did a bit of testing and found the following -

// Feed: Yes
insert new Task(WhatId = '5001R00000gS4OxQAK', Subject = 'Test'); 
insert new Task(WhatId = '5001R00000gS4OxQAK', Subject = 'Test', TaskSubtype='Task'); 

// Feed: Yes, but the wrong icon (Task instead of Call)
insert new Task(WhatId = '5001R00000gS4OxQAK', Subject = 'Test', TaskSubtype='Call');

// Feed: No
insert new Task(WhatId = '5001R00000gS4OxQAK', Subject = 'Test Email', TaskSubtype='Email');
insert new Task(WhatId = '5001R00000gS4OxQAK', Subject = 'Test List Email', TaskSubtype='ListEmail');

The phasing of the documentation quoted above is confusing and seems to contradict itself. Call Logs do leave Chatter posts via both the UI and the API, as do regular Tasks, but Emails and List Emails do not when sent via Apex (I didn't test emails in the UI).

I've worked on the Activity timeline before (link is to my blog) and found that there seems to be some behind-the-scenes magic going on in how the TaskSubtype is set and aligned to the visual presentation of the generated Chatter feed post - as seen here, when I try to synthesize a Call Log Task via Apex, and get a feed item that looks like a regular Task.

2
  • Thanks David. Out of interest, what type of object is being created to add an entry to the case feed? because if I query SELECT Id, Title, Body, Type, Status, RelatedRecordId, ParentId, LinkUrl, HasLink, HasFeedEntity FROM FeedItem WHERE ParentId = 'CASE_ID', I only get 1 record of type = CreateRecordEvent, but no record for the Call Task I created.
    – Robs
    Commented May 5, 2019 at 8:53
  • 1
    @Robs I'm finding the same thing, although the feed items do show in the UI. That seems mysterious - I'm not sure how the mechanism actually works here.
    – David Reed
    Commented May 5, 2019 at 14:23

You must log in to answer this question.

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