I am trying to get the topics of a FeedItem after it is created. TopicAssignment is the object that connects each FeedItem to its topics. I've created a trigger on FeedItem (after insert) that will run every time a new FeedItem is created. However, when querying TopicAssignment by EntityId in the trigger, nothing is returned. The query is shown here:
[SELECT TopicId, Topic.Name FROM TopicAssignment WHERE EntityId=:FeedItem.Id]
If I run the query in the Query Editor in the console, I get the TopicAssignment objects related to the topics. I suspect that TopicAssignment objects are not yet inserted into the database when the trigger is called. Is this the case, and is there a way I can work around this issue?
Any help is much appreciated!