Copying (duplicating) an appointment server-side

7 posts, 0 answers
  1. Dave
    Dave avatar
    26 posts
    Member since:
    Aug 2012

    Posted 08 Feb 2010 Link to this post


    We are wondering how to access the low-level appointment data (like recordset ID or internal references) in order to duplicate a selected appointment including all its settings to a new date in timeline view (v. Q2_2009).
    We were looking at the exposed properties without finding something, but I guess we certainly missed something...

    Edit: The selection of the appointment occurs through a contextual menu.

    This has to be done server-side for technical reasons.
    Anybody has an idea?

  2. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 08 Feb 2010 Link to this post

    I'm assuming the property you want is the Appointment.Clone(). This will return a duplicate of the appointment object.

    Is that what you're looking for?
  3. Peter
    Peter avatar
    6637 posts

    Posted 09 Feb 2010 Link to this post

    Hi David,

    In addition to Robert's suggestion, we have recently had a question on how to copy and paste an appointment using the context menu. Here is sample code for this functionality:

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"
            <telerik:RadScheduler ID="RadScheduler1" runat="server" OnAppointmentContextMenuItemClicking="RadScheduler1_AppointmentContextMenuItemClicking"
                <AppointmentContextMenuSettings EnableDefault="true" /> 
                    <telerik:RadSchedulerContextMenu ID="RadSchedulerAppointmentContextMenu1" runat="server"
                            <telerik:RadMenuItem Text="Copy" Value="Copy"
                <TimeSlotContextMenuSettings EnableDefault="true" /> 
                    <telerik:RadSchedulerContextMenu ID="RadSchedulerTimeslotContextMenu1" runat="server"
                            <telerik:RadMenuItem Text="Paste" Value="Paste"

    protected void RadScheduler1_TimeSlotContextMenuItemClicking(object sender, TimeSlotContextMenuItemClickingEventArgs e) 
           if(Session["appointment"] != null
               Appointment a = Session["appointment"] as Appointment; 
               //The following achieves cut and paste: 
               //RadScheduler1.DeleteAppointment(a, true); 
               TimeSpan appDuration = a.Duration; 
               a.Start = e.TimeSlot.Start; 
               a.End = e.TimeSlot.Start.Add(appDuration); 
       protected void RadScheduler1_AppointmentContextMenuItemClicking(object sender, AppointmentContextMenuItemClickingEventArgs e) 
           Session["appointment"] = e.Appointment; 
       protected void Page_Init(object sender, EventArgs e) 
           XmlSchedulerProvider provider = new XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), true); 
           RadScheduler1.Provider = provider; 

    Attached is a simple demo for reference.

    Kind regards,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  4. Christopher
    Christopher avatar
    3 posts
    Member since:
    Jan 2017

    Posted 19 Jan 2017 in reply to Peter Link to this post

    This almost works for what I am trying to do.  One thing that I need to be able to do is nullify a custom attribute (primary key to the table) so that instead of editing an existing record in the database, I insert a new record.
  5. Christopher
    Christopher avatar
    3 posts
    Member since:
    Jan 2017

    Posted 20 Jan 2017 in reply to Peter Link to this post

    I basically have the desired result I want except my calendar is not rebinding once I insert my record into the database.  I have to close and rerun the page to see the new appointment.  Here is my code...

        Private Sub RadScheduler1_TimeSlotContextMenuItemClicking(sender As Object, e As TimeSlotContextMenuItemClickingEventArgs) Handles RadScheduler1.TimeSlotContextMenuItemClicking
            If Session("appointment") IsNot Nothing Then
                Dim oSched1 As Appointment = Session("appointment")
                Dim oSched2 As Appointment = Nothing
                Dim appDuration As TimeSpan = oSched1.Duration
                oSched1.Start = e.TimeSlot.Start
                oSched1.End = e.TimeSlot.Start.Add(appDuration)

                Dim oScheduledShipment As New tScheduledShipment
                Dim oNewShipment As New tScheduledShipment
                With oScheduledShipment
                    .ShipmentID = oSched1.Attributes.Item("ShipmentID")
                    .OriginAssetID = oSched1.Attributes.Item("OriginAssetID")
                    .DestinationID = oSched1.Attributes.Item("DestinationID")
                    .Vessel = oSched1.Attributes.Item("Vessel")
                    .CarrierID = oSched1.Attributes.Item("CarrierID")
                    .ScheduledTons = oSched1.Attributes.Item("ScheduledTons")
                    .ScheduledShipDate = oSched1.Start
                    .ExpectedArrivalDate = oSched1.End
                    .ActionID = 1
                    .ActionBy = "chrisruckman"
                    .ActionMachine = "abc"
                    .ActionDate = Date.Now
                End With

                Using o As New CIMSLogisticsService.ScheduledShipmentsClient
                    oNewShipment = o.InsertScheduledShipment(oScheduledShipment)
                End Using

                oSched2 = New Appointment
                With oNewShipment
                    oSched2.Attributes("ScheduledShipmentID") = .ScheduledShipmentID
                    oSched2.Attributes("ShipmentID") = .ShipmentID
                    oSched2.Attributes("OriginAssetID") = .OriginAssetID
                    oSched2.Attributes("DestinationID") = .DestinationID
                    oSched2.Attributes("Vessel") = .Vessel
                    oSched2.Attributes("CarrierID") = .CarrierID
                    oSched2.Attributes("ScheduledTons") = .ScheduledTons
                    oSched2.Attributes("ScheduledShipDate") = .ScheduledShipDate
                    oSched2.Attributes("ExpectedArrivalDate") = .ExpectedArrivalDate
                    oSched2.Attributes("ActionID") = .ActionID
                    oSched2.Attributes("ActionBy") = .ActionBy
                    oSched2.Attributes("ActionMachine") = .ActionMachine
                    oSched2.Attributes("ActionDate") = .ActionDate
                End With


                'RadScheduler1.DataSource = ScheduledShipments()
            End If
        End Sub


  6. Christopher
    Christopher avatar
    3 posts
    Member since:
    Jan 2017

    Posted 20 Jan 2017 in reply to Christopher Link to this post

    I fixed it.  My ScheduledShipments wasn't populating the datasource because it was checking to see if a session variable was being set.  I simply set the session variable to nothing and called the ScheduledShipments to set the data and called the scheduler's databind methog.  I removed .Rebind because it was undoing the databind()


                    RadScheduler1.DataSource = Nothing
                    Session(SCHEDULEDSHIPMENTS_DATA) = Nothing

                    RadScheduler1.DataSource = ScheduledShipments()

  7. Veselin Tsvetanov
    Veselin Tsvetanov avatar
    1187 posts

    Posted 24 Jan 2017 Link to this post

    Hi Christopher,

    Thank you for shearing the approach you have chosen, in order to resolve the issue faced.

    Veselin Tsvetanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top