You need to sign in to do that
Don't have an account?
Basil Choudhry
Pushing Event DateTime into an Email Template
I've got an email template with various merge fields, one of which is the Event Time, however, it refuses to push the event time through into the email. Other non-event merge fields work fine (Contact name, User name, account name etc). It appears that the issue is because Events don't have a standard parent-child relationship with other objects and because you can't send an email directly from an Event but have to do it from an Account/Opportunity.
All I want to be able to do is book an event, and then have an email template that includes the date & time of the event to send to the customer.
Is there a workaround that can be used for this?
All I want to be able to do is book an event, and then have an email template that includes the date & time of the event to send to the customer.
Is there a workaround that can be used for this?
If anyone needs it, this was the solution:
trigger TriggerOnEventInsert on Event (after insert) {
ID parentID = null;
for(Event newEvent : Trigger.new)
{
if (newEvent.WhatId != null)
{
parentID = newEvent.WhatId;
if(newEvent.ActivityDateTime != null)
{
String objectAPIName = parentID.getSObjectType().getDescribe().getName();
if(objectAPIName.equalsIgnoreCase('Opportunity'))
{
Opportunity thisOpportunity = [Select ID, EventDate__c from Opportunity where Id = :parentID];
thisOpportunity.EventDate__c = newEvent.ActivityDateTime;
update thisOpportunity;
}
else if (objectAPIName.equalsIgnoreCase('Case'))
{
Case thisCase = [Select ID, EventDate__c from Case where Id = :parentID];
thisCase.EventDate__c = newEvent.ActivityDateTime;
update thisCase;
}
}
}
}
}