Recurring appointments

Posted by: fsegui on 20 July 2023, 2:55 pm EST

    • Post Options:
    • Link

    Posted 20 July 2023, 2:55 pm EST - Updated 20 July 2023, 3:00 pm EST

    Hi,

    We’re using C1Schedule binded to a database.

    For performance reason, we reduce the appointments loaded by filtering appointments based on the schedule selected dates.

    We want to add the possibility to manage recurring appointments but with our filtering system, if we have a recurring appointment each week, it’s only displayed when the master appointment is in the range.

    Is there an easy way to get the recurring appointments? Or is it possible to save recurring appointments in database apart from the master one?

    See GIF & sample attached.

    Thanks

    C1ScheduleDemo.zip

  • Posted 21 July 2023, 9:27 am EST

    Hi Florent,

    When a recurring appointment is created, only a single appointment object (master) is created in the AppointmentStorage and it is just shown on multiple days as per its recurrence schedule. When the Master appointment goes out of the visible date range, it is cleared from the storage because you re-fetch the appointments for the new date range, and it results in all the recurrences getting lost (due to the master appointment being lost).

    We have attached a video showing the same of what is explained above Recurring Appointments.zip . Due to this architecture of C1Schedule, there is no way to store the recurrences of a recurring appointment in the Database.

    There is only one workaround we could think of in this scenario, where, when the Visible date range is changed and you update the Table, instead of clearing the previously loaded appointments and refilling the Table, you can append the appointments (of the new visible date range) to the existing table.

    Best Regards,

    Kartik

  • Posted 21 July 2023, 11:07 am EST

    Hi Kartik,

    Thanks for your quick feedback.

    I’ve find another way to get the recurring appointments not in range by adding a dedicated column in the database. When saving a recurring appointment, I’m updated this column, therefore I can include this appointment in the select command.

    Another question: How can we modify the recurrence settings by code?

    I have several cases to cover:

    • deleting a specific ocurrence (I’m not using the built-in context menu)
    • creating a recurrence pattern (I’m getting recurring events from Google API).

    Thanks

    Florent

  • Posted 24 July 2023, 3:05 am EST

    Hi Florent,

    We are glad to hear that you were able to implement your requirement. To modify the recurrence of an appointment through code, you can use the ClearRecurrencePattern and GetRecurrencePattern methods of the appointment. Please refer to the code snippet below for reference.

    
    //Clear the existing recurrence pattern
    c1Schedule1.DataStorage.AppointmentStorage.Appointments(0).ClearRecurrencePattern()
    
    //Get the new RecurrencePattern object and customize it as per your requirement
    Dim recur = c1Schedule1.DataStorage.AppointmentStorage.Appointments(0).GetRecurrencePattern()
    

    Best Regards,

    Kartik

  • Posted 24 July 2023, 4:33 pm EST

    Hi Kartik,

    I’ve almost achieve my target.

    I still have one issue with recurring events linked to Google Agenda.

    Let’s say I have a recurring event in C1Schedule, happening every day at 10am from 24th of July to the 30th of July.

    I’ve synchronized this recurring event with Google Agenda.

    In C1Schedule, I move the instance of the 27th of July. How can I get through code that’s it’s the 4th ocurrence?

    As on Google side, I can only get the instance by its index.

    Thanks

    Regards

    Florent

  • Posted 24 July 2023, 4:33 pm EST

    Hi Kartik,

    I’ve almost achieve my target.

    I still have one issue with recurring events linked to Google Agenda.

    Let’s say I have a recurring event in C1Schedule, happening every day at 10am from 24th of July to the 30th of July.

    I’ve synchronized this recurring event with Google Agenda.

    In C1Schedule, I move the instance of the 27th of July. How can I get through code that’s it’s the 4th ocurrence?

    As on Google side, I can only get the instance by its index.

    Thanks

    Regards

    Florent

  • Posted 25 July 2023, 7:37 am EST

    Hi Florent,

    First, you can handle the BeforeAppoinmentDrop event. Further, when moving an occurrence of a recurring appointment, you can get the index of the occurrence by calculating it using the properties of the RecurrencePattern. Please see the attached sample project showing a simple implementation of the same.

    Attachment: ScheduleSample.zip

    Best Regards,

    Kartik

  • Posted 26 July 2023, 11:25 am EST

    I’ve found another way to do it and not be dependant on the recurrencetype :

    Dim apps As C1.C1Schedule.AppointmentList = C1Schedule1.DataStorage.AppointmentStorage.Appointments.GetOccurrences(eventArgs.Appointment.ParentRecurrence, eventArgs.Appointment.GetRecurrencePattern().PatternStartDate, eventArgs.Appointment.GetRecurrencePattern().PatternEndDate)
                                    Dim appList As List(Of C1.C1Schedule.Appointment) = apps.ToList()
                                    appList = appList.OrderBy(Function(x) x.Start).ToList()
    Dim indexOcurrence as integer = appList.IndexOf(eventArgs.Appointment)

    I’m running through another issue:

    When adding an appointment in C1Schedule, in the AppointmentAdded event I’m adding it to Google and getting back the id from Google. I’m then storing it in the CustomData.

    Doing that, it raises automatically an appointmentChanged event to store it. But I don’t want to raise that event.

    Do you have any ideas how to handle this?

    Thanks

    Regards

  • Posted 27 July 2023, 2:14 am EST

    Hi Florent,

    The AppointmentChange event will be fired when any change is done to an Appointment. When making changes to an appointment through code, what you can do is enclose that code between the Appointment.BeginEdit and Appointment.EndEdit methods. This will make sure that the change notification is not pushed for each change.

    To stop the final change notification, you can maintain a boolean flag that restricts the execution of the AppointmentChanged logic when the changes are done by code (in the AppointmentAdded event). Please see the attached sample project for reference.

    Attachment: ScheduleSample.Updated.zip

    Best Regards,

    Kartik

  • Posted 30 August 2023, 2:54 am EST

    Hi Kartik,

    I forgot to answer.

    It works with your inputs.

    THanks

    Best regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels