You need to sign in to do that
Don't have an account?
Trigger email alert when new ideaComment added
I am trying to create a trigger that sends an Email Alert (or just an email though Apex code) to the original Idea poster whenever a comment is left for their idea. In looking through the Apex documentation, I noticed it says you can only define triggers for top-level standard objects, but not for standard child objects. When I try to do something like this:
trigger commentEmail on IdeaComment (after insert) { // send email code here }
I get "Error: Compile Error: SObject type does not allow triggers: IdeaComment at line 1 column 25". Can anyone point in the right direction to get around this?
Any reason why you cannot just use a workflow for this?
You can specify the workflow to fire whenever the record is created or updated (I am assuming a comment counts as an update but I am not 100% certain). Then you can fire the email to the record creator using standard workflow actions.
edit
I think you can say in the rule criteria:
Last Commented Date equals today().
This should cause the workflow to fire whenever a comment is added
Maybe a little bit late but we are firing workflow on Idea when a comment is being posted using the following criterias:
Then the workflow rule sends an email to the Idea Creator.
Regards,
It appears that the idea trigger fires when comments are added, the field that changes on the idea is
LastCommentDate
so you could use this to inspect comments on an idea. it's not exactly a trigger on idea comment but is useful
can any ont tell me how to trigger email alert when new idea is promoted to 20 or 30 points??
Amazingly, Salesforce Ideas still has no feature allowing idea submitters, previous voters, or previous commenters to receive email notifications of future comments.
I took a shot at writing a trigger for this, but ran into a roadblock - the Idea.Comments collection seems to come back empty, even though Ideas.numComments increments. Code snippet:
Surprisingly, after you create an idea and post the first comment, you'll see numComments = 1, but the Comments collection is empty, even though it's an "after update" trigger.
Any suggestions on why this is happening?
This should work:
Thanks Benito, but your code doesn't address the issue I noted, which is that the Comments collection won't have the latest comment record in it. So you can't insert it in the email, which defeats the purpose of the trigger.