• Bum Alex
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

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){
    if(!Date2Event.containsKey(dateMapKey(e.CreatedDate))){
         Date2Event.put(dateMapKey(e.CreatedDate), new list<Event>());
     }
     Date2Event.get(dateMapKey(e.CreatedDate)).add(e);
}

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.
I am creating a form in Visualforce. Since my form is a bit long, it is hard for users to remember the error message at the top and revise it. On top of the error message, I want to create a validation when users typing in their information.
For example, there are 2 field, users name and email. Users cannot leave the name field blank, if so, I want to show a message of "This field is required to fill in" beside the field. And for email field, I want to have another message to remind users to insert a valid email.
Is there anyway in visualforce to do so? Thanks for your help.