Defaulting Start and End Date/Time for New Events

  • 1
  • Question
  • Updated 1 year ago
  • Answered
I've got a button on the opp detail page that uses row actions to create a new event and displays it in a popup.  Similar to the standard SFDC functionality, I'm looking to set the default start date/time to the beginning of the next hour and the end date/time to the start date/time + 60 mins.

For example, if I create the event as 1/30/2015 @ 12:13pm, the start date/time should default to 1/30/2015 @ 1:00pm and the end date/time should default to 1/30/2015 @ 2:00pm.

Any ideas?
Photo of Will Soupcoff

Will Soupcoff

  • 734 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
This cannot be done declaratively.   The best you can do is create a default value in the create new row action using the date literal "TODAY"  which will put current time into the field.  To get more specific time manipulation you'd need to create a custom renderer on the fields in the popup that populated them with data you calculated in javascript. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
How about updating the row with calculated times. 

newEventModel.updateRow(eventRow, fields)

Times could be calculated as described in javascript.

Set the row action to create a new row in it's own model.

Set an snippet action on the row when new rows are created. 
Photo of Monica Lorey

Monica Lorey

  • 384 Points 250 badge 2x thumb
This is one of those things that would make me a hero...but I don't know enough (read: any) javascript to make it happen.  Is it ... maybe ... floating around somewhere that I could borrow it?  :P
Photo of Timothy Moore

Timothy Moore

  • 60 Points
I'd like to just set default times of 9 to 5 but keep the day the user clicked on the calendar