• Jonathan Kimberly
  • 0 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

I am working on trying to group my Event data with maps. What I am trying to accomplish is to group my Events in weeks > bookers > roll up count for booked appt for each week. My logic so far is:

map<string,list<Event>> Date2Event = new map<string,list<Event>>();
for(Event e: eventLst){
         Date2Event.put(dateMapKey(e.CreatedDate), new list<Event>());

public string dateMapKey(datetime dt){
    	datetime myDt = dt;
    	date myDate = myDt.date();
    	date StartOfWeekDate = myDate.toStartOfWeek();
    	string mapKey = StartOfWeekDate.format() + '-' + StartOfWeekDate.addDays(6).format();
    	return mapKey;

So I have a function that is basically setting the map's key with a string of start date to end date. So far what I have accomplished is to group the events by week. Now I need to nest the grouping more and group by week and by bookers, then roll up count for each booked appt for that week. Any ideas would be greatly appreciated. Thanks.