Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Changing appointment end time upon selecting type

Hi Forum.

I'm trying to create a script, where the default time slot for an appointment changes, depending on the type of appointment.

Its sparse with appointment Events, but is it something you think can be done with the OnAppointmentFieldsChanged Method?

 

Som det er nu, da er det kun muligt at angive en aftale som at være ’Hele dagen’, eller generelt for alle aftaler at sætte et standard tidsrum.

RE: Changing appointment end time upon selecting type

I just read that it just triggers on save. Is there another way to do this then?

Af: Kasper Rosenlund 7. sep 2017

RE: Changing appointment end time upon selecting type

Developing VB Scripts event handlers requires an investment!

Here is something that might get you started:

----------------- Test.vbs -------------------

Sub OnCurrentAppointmentFieldChanged( fieldName )
    If CurrentAppointment.Identity = 0 Then
        If StrComp( fieldName, "appointment.task_idx", vbTextCompare ) = 0 Then
            UpdateDuration()
        End If
    End If
End Sub

Sub OnViewShown( hWnd, fullPath )
    If StrComp( fullPath, "MainWindow.AppointmentDialog", vbTextCompare ) = 0 Then
        If CurrentAppointment.Identity = 0 Then
            UpdateDuration()
        End If
    End If
End Sub

Sub UpdateDuration()
    If CurrentAppointment.Task.Id = 6 THEN
        CurrentAppointment.Duration = 268
    End If
End Sub

--------------------------------------------------

Change the Task.Id = 6 to whatever your required type is!

Conrad

 

Af: Conrad Weyns 8. sep 2017