You need to sign in to do that
Don't have an account?
Help with a Trigger
I am currently using two objects in the picture
Account & Case
Account has a field Time_Zone__c which is a picklist with values EST , PST , CST ,MST
Case also has the same field Time_Zone__c
I have written trigger on case which pulls the TimeZone automatically based on the Account Field.
Till here no issues
I have one more Field Client _Date__c(Date/Time) on Case which takes the same value as Created Date
I have done this by just giving
Client_Date__c=System.Now()
My main issue is
The Client_Date__c is taking the time zone of the created by user .But I want this to get updated based on Time Zone field on Case which is pulled from Account
so you want the client_date__c to reflect the timezone selected on timezone field on accounts.
use the format method.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm
Modified this a bit by adding the Timezone.
Datetime GMTDate =
Datetime.newInstanceGmt(2011,6,1,12,1,5);
String strConvertedDate =
GMTDate.format('MM/dd/yyyy HH:mm:ss',
'EST');
// Date is converted to
// the new time zone and is adjusted
// for daylight saving time.
System.assertEquals(
'06/01/2011 07:01:05', strConvertedDate);