You need to sign in to do that
Don't have an account?

hard code date field in apex trigger
Hi All ,
I have wriiten a very simple trigger which will update the field value based on the start date. This startd date is custom date field (start_date__c). The trigger is below. I want to hard code the date field value in IF condition, I cannot hard code that field or i dont know how to hard code date field.Can you please help me ?
trigger convertedamountGBP on Schedules_and_Actuals__c (before insert,before update) {
for ( Schedules_and_Actuals__c sch : trigger.new)
{
if (sch.Start_Date__c = '2014-01-01')
{
sch.Converted_Amount_GBP__c = sch.Converted_currency_USD__c*2 ;
}
}
}
I have wriiten a very simple trigger which will update the field value based on the start date. This startd date is custom date field (start_date__c). The trigger is below. I want to hard code the date field value in IF condition, I cannot hard code that field or i dont know how to hard code date field.Can you please help me ?
trigger convertedamountGBP on Schedules_and_Actuals__c (before insert,before update) {
for ( Schedules_and_Actuals__c sch : trigger.new)
{
if (sch.Start_Date__c = '2014-01-01')
{
sch.Converted_Amount_GBP__c = sch.Converted_currency_USD__c*2 ;
}
}
}
if ( sch.Start_Date__c == Date.newInstance( 2014, 1, 1 ) )
-Glyn
All Answers
if ( sch.Start_Date__c = Date.newInstance( 2014, 1, 1 ) )
Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
Twitter: @GlynAtClosedWon
if ( sch.Start_Date__c == Date.newInstance( 2014, 1, 1 ) )
-Glyn