Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement