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

problem to retrieve month value from date in trigger
trigger Behr_AmountOfMonths_US on THD_Sales__c (after insert,after update) { Set<Id> accset = new Set<Id>(); Set<Id> thdset = new Set<Id>(); List<THD_Sales__c> thdlst = new List<THD_Sales__c>(); list<account> acclist = new list<account>(); Map<Id,THD_Sales__c> thdmap = new Map<Id,THD_Sales__c>(); map<Id,Double> AccountMap = new map <Id,Double>(); for(THD_Sales__c thd : Trigger.new) { if(thd.POS_Order_Type__c == 'Special Order' && MONTH(thd.Month_Year__c)=1) { accset.add(thd.SFDC_Account_ID__c); } } for(AggregateResult q:[SELECT SFDC_Account_ID__c sfdcAccId,sum(Amount__c)tot FROM THD_Sales__c where SFDC_Account_ID__c in :accset group by SFDC_Account_ID__c]) { //AccountMap.put((Id)q.get('SFDC_Account_ID__c'),(Double)q.get('expr0')); Id sfdcId = (Id) q.get('sfdcAccId'); Double dTotal = (decimal) q.get('tot'); AccountMap.put(sfdcId, dTotal); } }
Error: Compile Error: Method does not exist or incorrect signature: MONTH(Date) at line 11 column 56
if(thd.POS_Order_Type__c == 'Special Order' && MONTH(thd.Month_Year__c)=1)
Use this:
if(thd.POS_Order_Type__c == 'Special Order' && thd.Month_Year__c.month() =1)
Refer this:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_date.htm