I have a Map with Date Like Key and all Event on that day as a List of values. Here the code I use to create the map:

Map<Date,List<Event>> mappaeventidate= new Map<Date,List<Event>>(); 
    for(Event e:eventi_tutti){
            mappaeventidate.put(e.StartDateTime.date(),new List<Event>{e});

Now I need to clone the map, and after to delete the map I created before. I'm trying to use deepclone but I have a error. Here my code:

Map<Date,List<Event>> mappaeventidate2 =mappaeventidate.deepClone();

and the error when I save the trigger:

Operation only applies to SObject value map types: Map<Date,List<Event>>

I need to delete the List of Events inside the Map but before I want to store them in another Map. Is it possible?

  • Do you need to delete the events, or just clear the map? Jul 25, 2016 at 11:06
  • delete this events and after few operations reinsert them again Jul 25, 2016 at 11:11

1 Answer 1


I solve the problem with this code.

Map<Date,List<Event>> mappaeventtwo= new Map<Date,List<Event>>(); 
    for(Date d:mappaeventidate.keySet()){
        mappaeventtwo.put(d, mappaeventidate.get(d).deepClone());

if anyone needs it

  • Thanks mate. This was really helpful. Jun 12, 2022 at 11:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .