SHARE
TWEET

Untitled

a guest Jun 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Map<Id,Event> ObjYourMAp  = new Map<Id,Event>();
  2. // add some values in Map
  3. Map <Id,Event> MapLeadEvent = new Map <Id,Event>();
  4. for(Event objEvt : ObjYourMAp.Values())
  5. {
  6.     //-----------------getObjectName
  7.     String sObjName = (objEvt.WhoId).getSObjectType().getDescribe().getName();
  8.     if(sObjName == 'Lead')
  9.     {
  10.         if(MapLeadEvent != null && MapLeadEvent.containsKey(objEvt.Id) )
  11.         {
  12.             if(MapLeadEvent.get(objEvt.Id).CreatedDate < objEvt.CreatedDate)    
  13.                 MapLeadEvent.put(objEvt.WhoId,objEvt);
  14.         }
  15.         else
  16.         {
  17.             MapLeadEvent.put(objEvt.WhoId,objEvt);
  18.         }
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top