Equipment schedule chart - onEventDropped

Hello everyone,

I have an equipment schedule chart with some events scheduled (I pick up these events from a sql database, binding “schedule events” data property with a named query).
What I want to do now is to re-plan these activities by drag and drop them. For this purpose, inside the chart function “onEventDropped” I script this:

newStartDateObject =
newStartDate =,"yyyy-MM-dd HH:mm:ssX")
newEndDateObject =
newEndDate =,"yyyy-MM-dd HH:mm:ssX")
params = {"planned_start_datetime":newStartDate, "planned_end_datetime":newEndDate, "id_activity":eventId}
system.db.runNamedQuery("skf/planning_updates", params)

I have an issue with this code because it not works. When I try to drag & drop an event, it will snap back to the old position.
However,I also ran the script in scripting console and it works (SQL database will be updated).

Is the script ok? Any thoughts?

1 Like

I am trying to achieve the same thing. please do post here if you figure this out.

I could not get it to work either. It has something to do with running the named queries, I added

system.gui.messageBox("I got this far")

to the code (moving it from line to line) and it never gets past the runNamedQuery part. Unless someone here replies, I would definitely contact support since there are no examples in the user manual

Was there ever a resolution to this?

I have a solution that works for 8.1 (Vision). I spent quite a bit of time trying to get this component to actually render the changes visually. I could not find an example for implementing this functionality.

Equipment schedule events are controlled by datasets. Datasets as an entity in Ignition are immutable, meaning they cannot be modified. This is overcome by creating a copy of the original dataset, modifying the desired data or the entire set, and create a new dataset. This new dataset is then assigned to the data property on the equipment schedule component.
The event handler parameters give hints to the scripting functions needed for data manipulation.
Sampling of parameters for the ‘onEventDropped’ event handler, for dragging and dropping(moving) an event.
• oldStartDate: The original starting datetime of the event
• oldEndDate: The original ending datetime of the event
• newStartDate: The new starting datetime of the event
• newEndDate: The new ending datetime of the event
The challenge then, is accessing these parameters to create a new dataset to then assign to the equipment schedule so that our GUI event edits are rendered on the component.
First, I have the following script on the ‘onEventClicked’ handler that pulls out the eventId and stores it in a tag variable as I need this identifier to perform a search on the dataset in the ‘onEventDragged’ or ‘onEventResized’ handler. This step may not be needed in all cases but was required for mine at the time.

def onEventClicked(self, itemId, eventId, event):
	# Put your code here:
	# writing out eventId to user edit tag
	system.tag.write("[client]DowntimeWind/UserEdit/SelectedEvent", eventId)

Example manipulation scripting below:

def onEventDropped(self, eventId, oldItemId, newItemId, oldStartDate, oldEndDate, newStartDate, newEndDate):
    # Put your code here:
    system.tag.write("[client]DowntimeWind/UserEdit/OldEventEnd", oldStartDate)
    system.tag.write("[client]DowntimeWind/UserEdit/OldEventStart", oldEndDate)
    system.tag.write("[client]DowntimeWind/UserEdit/NewEventStart", newStartDate)
    system.tag.write("[client]DowntimeWind/UserEdit/NewEventEnd", newEndDate)
    #1 = label    #2 = eventid    #3 = StartDate    #4 = EndDate    #5 = Background        #6 = Layer
    TempDS ="[client]DowntimeWind/UserEdit/TempDS").value
    # Event ID of the selected and edited (dragged) event
    editedEventID = eventId
    # Converting to pyDataSet
    pyTempDS = system.dataset.toPyDataSet(TempDS)
    # Get the index of the row of the currently selected event
    rowIndex = -1 #start at -1 for Zero based index
    for row in pyTempDS:
        rowIndex = rowIndex + 1
        colIndex = -1 #start at -1 for Zero based index
        for col in row:
            colIndex = colIndex + 1
            if col =="[client]DowntimeWind/UserEdit/SelectedEvent").value: #editedEventID: #eventId:
        break # else: continue break statement links inner loop break with outer loop break
    newData = system.dataset.setValue(pyTempDS, rowIndex, "StartDate", newStartDate)
    newData = system.dataset.setValue(newData, rowIndex, "EndDate", newEndDate)
    newData = system.dataset.toPyDataSet(newData)
    # Updating component data for both the equipment schedule and a separate events table
    self.parent.parent.getComponent('Event Data Editing').data = newData
    self.scheduledEvents = newData
    # Write newData back to TempDS tag
    system.tag.write("[client]DowntimeWind/UserEdit/TempDS", newData)

Script Summary

  1. The underlying data for the equipment schedule is stored in a client dataset tag. This tag is read in and converted to a pyDataset for easy iteration.
  2. The pydataset is looped through until we find a match on the event that was modified (dragged and dropped).
  3. Once we match, we use the system.dataset.setValue() function to modify the start or end timestamp. (Both in this case, as the entire event was dragged). This doesn’t set a value rather, creates a new dataset with this new value.
  4. This new dataset is then assigned to the scheduledEvents parameter on the equipment schedule.
    Rendering the event data on the equipment schedule is relatively simple and can have potential value. However, much more functionality is made available when we can use the equipment schedule to modify the underlaying data and render those changes visually.
    After the data has been successfully updated on the component, it’s up to the developer to decide what to do with this new data. Besides rendering visually, we may want to feed it back to a master schedule dataset. This can be done by storing it in a satellite variable like a tag (TempDS in example above).