You need to sign in to do that
Don't have an account?
Ludivine
trigger emailAlert on Event
Hi Team,
Currently, I am unable to set up an email alert for the Event object, the standard functionality does not allow you to set up workflow email for Events and Tasks. Only way to overcome that is create a trigger.
I have searched a lot but didn't find how to write this EmailAlert on Event object.
If it is possible, could you show me a sample code to fire an email alert to "CreatedBy" and "Assigned To" users when End Date of the Event is Overdue ( EndDateTime > Today() ) ?
Many thanks for your help,
Regards,
Ludivine
Currently, I am unable to set up an email alert for the Event object, the standard functionality does not allow you to set up workflow email for Events and Tasks. Only way to overcome that is create a trigger.
I have searched a lot but didn't find how to write this EmailAlert on Event object.
If it is possible, could you show me a sample code to fire an email alert to "CreatedBy" and "Assigned To" users when End Date of the Event is Overdue ( EndDateTime > Today() ) ?
Many thanks for your help,
Regards,
Ludivine
All Answers
Hi,
I'm just taking a swag at it - this is unchecked code;
This trigger just fires an email out on creation of an event.
The other requirment of yours is a little trickier - I would think you have to set up a batch apex class that looks for all events with that searcg criteria, and then uses code similar to the above that notifies users.
Beware of governor limits regarding emails!
Wahoo fantastic, it works like a charm!
I will see for the Apex class if this is not enough for our users, for the moment It is exactly what I was looking for, many many thanks to you!!
Can I ask you how I can retrieve the value in the What field?
Actually, I have the id in the email near " Related To "and I would like to the see text instead.
Thanks again!
Hi Syntaxis,
Glad the code is some help to you.
Can you post a picture of what the problem is?
I having a problem picturing in my mind what's going on.
Thank you for dealing with my case.
By my question I meant I would like to add the "Related To" (WhatId) field ( from Event form) on the email alert as well.
When I tried to add this field like the others it shows me an error.
How can I retrieve lhe text value of the field ( related To field) in that trigger? thx
There wer just a couple template items that were in the wrong order - and when making a map from a SOQL statement that has the ID as the key, you should select the ID as the first item inthe statement. Those were the only changes I made and it seems to be working -- give it a shot;
Including a link to the event, contact, lead, etc is often a good idea - so when your CSRs get the email via mobile, they can just click on the link and go right to the record, and then click on the phone # -- it's a great time saver for them.
Yes it's a fantastic idea to add a link to the record instead, how can I do that?
Great it works fine now! Many many thanks!!
I read that I had to make a test class for code coverage, is it mandatory for triggers ?
Try this test class;
Thanks a lot!
I have now an issue with the what ID element on the event form.
it works for Events related to Opportunitunities but it doesn't work for the Events related to an Account
,
I have added the argument in my trigger but there must be a mistake ..
"Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Trigger_Event_Send_Email caused an unexpected exception, contact your administrator: Trigger_Event_Send_Email: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Trigger_Event_Send_Email: line 41, column 1
Trigger is :
many thanks!!