You need to sign in to do that
Don't have an account?
Compile:Error On triger
if(T.Completion_Date__c != NULL){ T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(CreatedDate); } Error :
T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(T.CreatedDate); } Error :
|
The Code :
trigger UpdateTypePicklist on Task(before update) {
String Curr = Userinfo.getDefaultCurrency();
for(Task T: Trigger.new){
//Create an old and new map so that we can compare values
Task oldT = Trigger.oldMap.get(T.ID);
Task newT = Trigger.newMap.get(T.ID);
//Retrieve the old and new Status Value
String OldStat = oldT.Status;
String NewStat = newT.Status;
if((T.Type__c != NULL)&& (T.RecordTypeId == '012S0000000DIPs'))
{
T.Type = T.Type__c;
}
if(OldStat!= NewStat){
T.Status_Update_Date_Time__c = DateTime.now();
if(T.Status == 'Completed'){
T.Completion_Date__c = Date.Today();
}
if(T.Completion_Date__c != NULL){
T.No_Of_Days_Open__c = T.Completion_Date__c - DATEVALUE(T.CreatedDate);
}
}
If((T.CurrencyIsoCode!= Curr)&&((T.Type__c!='Estimate')&&(T.Type__c!='Quote'))){
T.adderror('Activity Currency Should not be updated');
}
}
}
Hi
try using the below code:
Hope this helps!
Regards
Sam
All Answers
DATEVALUE is a formula function, so you can't use that in apex. Instead you should use the date method exposed by the datetime primitive:
Hi
try using the below code:
Hope this helps!
Regards
Sam
It should be 'T.createdDate.date()' in my code sample above.