Page 1 of 1

Trouble setting default event end time

PostPosted: Thu Sep 02, 2010 1:20 pm
by jimrecht
Hi John:
I followed the directions here:

http://www.seedcode.com/pmwiki/pmwiki.php?n=SeedCodeCalendar.EventDuration,

changing "1200" to "1800" to create a default event duration of 30 minutes. When creating new records this works fine. But when I edit an existing event's Start Time, the End Time remains unchanged. I want the End Time to "update" whenever the Start Time changes, to retain the default 30" duration. (I also want the Date End field to be modifiable, so that the user can "manually" enter any end time -- if she wants to make a given event last longer than 30" for example).

So here are the Events::Time End settings:

Field Type: Time
Formula/Entry Option:
Indexed, Auto-enter calculation: from Events, =
Let ( [
d = 1800 ; // Default event duration in seconds t = If ( IsEmpty ( Self ) and not IsEmpty ( TimeStart ) ; TimeStart + d ; Self ) ; t= Case ( t = Time ( 24 ; 0 ; 0 ) ; Time ( 24 ; 0 ; 1 ) ; t > Time ( 24 ; 0 ; 0 ) ; t - Time ( 24 ; 0 ; 0 ) ; t) ]; t )
Evaluate even if all referenced fields are empty, replaces existing value


How should I change this to get what I really want?

Yours,
Jim

PostPosted: Thu Sep 02, 2010 4:38 pm
by John Sindelar
If you have the"Do not replace existing value..." unchecked then the end time will adjust as you change the start time but you won't be able to change the end time to something other than your duration.

In order to get the behavior you want you probably need a third field. Some people do the third field as a manually entered end time and then change the auto enter calc to use it if it isn't empty, but I think a "duration" field makes sense for the third field. Default THIS duration field to 30 minutes and replace the "d" in your auto enter with a reference to this new duration field. Now users can change the duration field if they want the event to be longer.

You can even clear the default duration field in some cases (such as when users drag an event's end time on the calendar) so it stops getting in the way if users really want to play with the event's time.

Hope that helps,

John