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
Lakshmikanth__SLakshmikanth__S 

Invoking trigger when an answer is marked as Best Answer in Chatter

I am trying to invoke a trigger when an answer is marked as Best Answer in Chatter (not in Community). I tried a trigger on FeedItem and FeedComment objects, but the triggers were not invoked when I mark an answer as a Best Answer. Can someone help?
Raj VakatiRaj Vakati
I think you have are using chatter answers .. so the trigger on the FeedItem and FeedComment  wnt work .. 

you need to use the Question  objects 

You have to BestReplyId  and BestReplySelectedById based on the requirement 


https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/api/sforce_api_objects_question.htm?search_text=Question
 
trigger BestAnswerTrigger on Question (before update) {
    for (Question q: Trigger.new) {
        if (q.BestReplyId!=null) {
           // Logic will go here 
        }
    }
}

​​​​​​​
Lakshmikanth__SLakshmikanth__S
It is a very new org created less than 6 months back and I am sure its Chatter Questions (not Chatter Answers). I tried creating a trigger on Question object, but I get an error Invalid type: Schema.Question while trying to save.
Navin Dayama 2Navin Dayama 2
Hi @Lakshmikanth__S

Did you find the answer to your question? I am facing the same issue. Can you please suggest how can we overcome this problem?