You need to sign in to do that
Don't have an account?
KatherineC
Chatter Feed Key Word Email Alert
Hi All,
We want to send out email alert when certain key words (like legal, tax) are mentioned in Chatter post. We notice Feed Item Trigger, can we use that to achieve this and how? Based on our research it seems Feed Item Trigger is for insert/delete post, can it trigger to send out email alert or create a new record? Ideally it can trigger to send out email alert, if not we're thinking to create a process like this, when someone mentions "legal" in the post, trigger will fire to create a record under a custom object we build and subsequently send out email alert by workflow rule. Any suggestions? Thanks.
We want to send out email alert when certain key words (like legal, tax) are mentioned in Chatter post. We notice Feed Item Trigger, can we use that to achieve this and how? Based on our research it seems Feed Item Trigger is for insert/delete post, can it trigger to send out email alert or create a new record? Ideally it can trigger to send out email alert, if not we're thinking to create a process like this, when someone mentions "legal" in the post, trigger will fire to create a record under a custom object we build and subsequently send out email alert by workflow rule. Any suggestions? Thanks.
Do you have any sample codes that can help me start? I'm new to apex coding. Thanks.
http://stackoverflow.com/questions/17047778/sending-email-with-template-using-trigger
http://stackoverflow.com/questions/17860289/apex-beginner-email-from-a-trigger
http://salesforce.stackexchange.com/questions/38947/sending-email-notification-using-trigger
https://developer.salesforce.com/forums?id=906F00000008yhSIAQ
http://www.sfdc99.com/2014/03/01/sending-emails-using-apex/
http://abhithetechknight.blogspot.sg/2013/10/send-email-using-trigger.html
Hope it helps.
Thanks so much for the links, lots of helpful information. Based on that we created a trigger and test class: when a new record under Keyword object is created, we want an email notification sends out automatically to record owner and confirm we receive his keyword request. But we got error message for test class, we don't know how to reference folderId for email template and could not find information that makes it work. Please help.
Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [FolderId]: [FolderId]
@isTest
public class SendKRNotificationTest
{
static testMethod void SendEmail()
{
Test.StartTest();
EmailTemplate et = new EmailTemplate (developerName = 'test', TemplateType= 'text', Name = 'test');
insert et;
Keyword__c k = new Keyword__c();
insert k;
Test.StopTest();
}
}
TRIGGER:
trigger SendKRNotification on keyword__c (after insert) {
keyword__c keyword = trigger.new[0];
String[] toAddresses = new String[] {keyword.email__c};
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(keyword.OwnerID);
mail.setSenderDisplayName('Admin');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
{
EmailTemplate et=[Select id from EmailTemplate where DeveloperName=:'Keyword_Request_Confirmation'];
mail.setTemplateId(et.id);
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}