I’m having some trouble with the DataProcessor occasionally not recognizing events that have been added to a dhtmlx schedule via addEvent. The problem only happens about 5% of the time, but when it does occur, it frequently happens with several transactions in a row. I believe it’s more likely to occur in sites with a slower Internet connection.
The problem occurs within a JavaScript function that swaps work shift events between two employees. The function uses deleteEvent to remove the original scheduler event, which updates the server data reliably. The subsequent addEvent method displays the new event correctly on the client browser, but occasionally does not trigger an insert on the server.
The code is shown below. I’ve been able to verify that the “onBeforeDataSending” event does not fire when the problem occurs. The getState method also returns “undefined” when executed immediately after the addEvent for transactions that have the problem.
// DELETE old shift
scheduler.deleteEvent(eventObj.id);
// INSERT new shift
var newEventObj = {
store: eventObj.store,
start_date: eventObj.start_date,
end_date: eventObj.end_date,
text: eventObj.text,
startBreak: eventObj.startBreak,
weekEnd: eventObj.weekEnd,
employeeID: newEmployeeID,
sectionID: newEmployeeID,
schedule: eventObj.schedule,
timeType: eventObj.timeType,
userID: "Swap:" + winId
};
var eventId = scheduler.addEvent(newEventObj);
scheduler.getEvent(eventId).eventKey = eventId; // save original eventId as eventKey
var syncState = schedulerDP.getState(eventId);
message("Swap INSERT:" + eventId + ", state = " + syncState, "LOG"); // syncState is sometimes undefined?
schedulerDP.attachEvent("onBeforeDataSending", function (id, state, data) {
message("onBeforeDataSending: ID" + dpId + ", state=" + state, "LOG"); // "DEBUG"
A typical transaction generates debug messages showing “state=inserted” followed by a onBeforeDataSending message:
A failed transaction generates debug message “state=undefined” without a onBeforeDataSending message: