1

In every user page we have a chatter that shows the user activity, which record he updated etc

enter image description here

How can i get that user's activity in a SOQL Query?

2

2 Answers 2

1

I ended up with this query, to get the user activity on a specific record:

SELECT Id,
    (Select FieldName, OldValue, NewValue FROM FeedTrackedChanges),
    CreatedDate,ParentId
FROM AccountFeed WHERE CreatedById = '<Id>' AND  CreatedDate > 2019-10-25T12:00:00.000+0000 and CreatedDate < 2019-10-25T13:00:00.000+0000

To query a different object, change the AccountFeed to the object's feed.

1
  • For those who would like to narrow down the query: it is not possible to query on FieldName. That produces the error: field 'FieldName' can not be filtered in a query call. Even though FieldName is a String according to the Salesforce documentation. Commented Mar 21, 2022 at 13:16
0

If you are referring to tracked changes such as Record modification you can use the FeedItem in a similar manner than the following:

select Id, Body, CommentCount, CreatedDate, LikeCount, LinkUrl, ParentId, RelatedRecordId, Title, Type from FeedItem WHERE CreatedById = '0056g000000xrvgAEI'

You can further get the changed values by querying the FeedItemTrackedChange object which you can pull by using the FeedItem id

If you are looking to pull all chatter comments under one of these changes it will require additional queries as well.

The short answer is if you were to want to rebuild this feed's look and feel by getting the queries yourself, it will require several queries AND preprocessing before loading.

3
  • I'm trying to find out what did a user do in a certain date and time, because we received an exception from production and don't know what did the user do at that time.
    – Dana Griff
    Commented Nov 12, 2019 at 9:14
  • I understand - If an exception occurred a tracked change will not be recorded so the chatter activity might not be the best solution to audit the user for an exception occurring. Salesforce offers a feature called "Event Monitoring" that gives more visibility into activity from end users. If the user helps you, ideally you should turn on debug logs and have them recreate this error. Can you post the error that was stated in the notification? Commented Nov 12, 2019 at 9:24
  • It's an error that was received by an automated process, probably code or integration. I don't know how to reproduce it and that's why we want to see what happened at that time.
    – Dana Griff
    Commented Nov 12, 2019 at 9:34

You must log in to answer this question.

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