function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dr. Thomas MillerDr. Thomas Miller 

How does Feeditem relate to Case?

I am seeing an extremely strange behavior:

I am creating a task from a case's activity timeline. After the creation (or during the creation, doesn't matter) I am changing the task's WhatId to an account.
Now, if in workbench or dev console I look at the FeedItem record its ParentRecordId is the task, and the task's WhatId is the account. So, looking at all data in workbench, there isn't any more any reference to the case.
Nevertheless, when looking at the same FeedItme in the SF UI, it still shows that the FeedItem is related to the case.
Where is this reference coming from (i.e. how is the link between FeedItem and Case represented in the database)?
SubratSubrat (Salesforce Developers) 
Hello ,

When you create a Task, a TaskRelation record is also created for each related record, such as the Case in your scenario. The TaskRelation record contains information about the related record, including the related record's ID and its relation to the task (e.g., whether it's the task's WhatId or WhoId).

When you change the WhatId on the Task to an Account, the TaskRelation record for the Case is deleted and a new TaskRelation record is created for the Account. However, the FeedItem still displays the original relationship to the Case because it's based on the historical data stored in the database.

In other words, the FeedItem is not dynamically updated based on the current TaskRelation records, but instead displays the relationship that was valid at the time the FeedItem was created.

Hope the above information helps !
Thank you.