You need to sign in to do that
Don't have an account?
Hi need help
Hi this is my code what i am doing is that i am updating a custum field with activitydate of task. But when my trigger fires the custom field is showing wrong value e.g.
ActivityDate ::: 24/7/2012
Custom Field ::: 23/7/2012
This custom field is also datetime field.
Here is my code::::::::::::::::::::::::::::::::::::::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<:::::::::::::::::::::::::::::::::::::::::::::::::
trigger UpdateTaskActivityTypeEmail on Task (before insert, before update) {
String subject;
for (Task tsk : trigger.new)
{
if(trigger.isInsert || (trigger.isUpdate && tsk.ActivityDate != trigger.oldMap.get(tsk.Id).ActivityDate))
{
tsk.Activity_Date__c = tsk.ActivityDate;
}
subject = tsk.Subject;
if (subject != null && subject.trim() != '' && subject.toLowerCase().contains('email:'))
{
tsk.aos__Activity_Type__c ='Email (customer or prospect)';
}
}
}
Any help is highly appreciated...
Abhi,
First thing, ActivityDate is NOT a Datetime field... Here you are trying to update datetime custom field from a Date field... If you still want this to happen you can use...
tsk.Activity_Date__c = datetime.newInstance(tsk.ActivityDate.year(),tsk.ActivityDate.month(),tsk.ActivityDate.day());
instead of tsk.Activity_Date__c = tsk.ActivityDate;
Hope this helps!