Ajax (1) Apex Class (12) Apex Trigger (2) Community (2) Home Page (1) HTML (4) Integration (3) JS (7) KB (1) Label (1) Licenses (1) Listing (1) Log (1) OOPs (5) Sharing (1) Static Resource (1) Test Class (3) URI (1) Visualforce (10)

Wednesday 26 February 2014

Method for updating Lead Rating Count on Custom Object

/*Method for updating Lead Rating Count on Custom Object names 'Configration'*/


  1. public void leadRatingCount(Map<id,Lead> triggerNewMap)
  2. {
  3. Map<String,Integer> objMap=new Map<String,Integer>{'Hot'=>0,'Warm'=>0,'Cold'=>0};
  4. for(Lead objLead:triggerNewMap.Values())
  5. {
  6. objMap.put(objLead.rating,objMap.get(objLead.Rating)+1);
  7. }
  8. Configration__c objConfigration=[select Hot_Leads__c,Warm_Leads__c,Cold_Leads__c from Configration__c limit 1];
  9. System.Debug('Hot value '+objConfigration.Hot_Leads__c+'plus'+objmap.get('Hot'));
  10. objConfigration.Hot_Leads__c +=objmap.get('Hot');
  11. objConfigration.Warm_Leads__c +=objmap.get('Warm');
  12. objConfigration.Cold_Leads__c +=objmap.get('Cold');
  13. update objConfigration;
  14. }


No comments:

Post a Comment