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
HarrySieHarrySie 

FeedItem.ID is null

Hello I've written a trigger to comment feeditems with special keywords. The problem is, that the feedItem.ID is null and so the insert comment fails. Why is the feeditem.ID null?

Best Answer chosen by Admin (Salesforce Developers) 
Alex.AcostaAlex.Acosta

If your trigger is set to before insert... you don't have an id yet. It needs to be inserted into the database first.

 

If you're just altering the data prior to insert you shouldn't need to do any DMLs on that particular record.

All Answers

Alex.AcostaAlex.Acosta

If your trigger is set to before insert... you don't have an id yet. It needs to be inserted into the database first.

 

If you're just altering the data prior to insert you shouldn't need to do any DMLs on that particular record.

This was selected as the best answer
HarrySieHarrySie

Hello Alex,

 

yes, that was a stupid question. I thought I implemented an after insert trigger, but in fact it was a before insert one.

 

Thanks

Harry


Alex.Acosta wrote:

If your trigger is set to before insert... you don't have an id yet. It needs to be inserted into the database first.

 

If you're just altering the data prior to insert you shouldn't need to do any DMLs on that particular record.


 

Alex.AcostaAlex.Acosta

There are no stupid questions Harry. I've made silly mistakes like this in the past, and hey, if it helps someone resolve a similar issue., then it makes the post worthy as well.