Hi,
I am having an issue with the onBeforeEventChanged event. When an event is changed via drag and drop I have a validation check run to make sure the user has permission to update an event. When the page is fresh and I move the event to a different area, I will receive an error message that it can’t be moved. But then the event does not go back to its original location. It will move to the correct time but not the correct resource. Any subsequent moves it will return it correctly. I’ve included the code that is executed and a zipped video showing what happens. Any clues as to what might resolve this issue?
scheduler.attachEvent("onBeforeEventChanged", function (ev, e, is_new, original) {
var updated = true;
var permissionName = '';
switch (ev.type) {
case "WorkOrder":
permissionName = "Service Appointments";
break;
case "Job":
permissionName = "Job Appointments";
break;
case "Technician":
permissionName = "Technician Activities"
break;
default:
permissionName = "";
}
if (COMMON.getPermission(permissionName, "CanEdit") == false) {
dhtmlx.alert({
title: "Error",
type: "alert-error",
text: $.i18n('EditPermissionDenied')
});
updated = false;
}
if (updated && ev.appointmentStatus == "COMPLETE") {
updated = false;
dhtmlx.alert({
title: "Error",
type: "alert-error",
text: $.i18n('CompletedAppointmentError')
});
}
if (updated) {
schedulerLayout.cells('b').progressOn();
var appt = APPOINTMENTDS.prepareAppointmentForSave(ev);
var updateResult = APPOINTMENTDS.updateAppointment(appt);
if (updateResult.result == true) {
var data = updateResult.data;
data.start_date = data.start_date.replace('T', ' ').replace('Z', '');
data.end_date = data.end_date.replace('T', ' ').replace('Z', '');
data.color = SCHEDULECOLORSFORM.getColorForProperty(data.appointmentStatus);
scheduledApptsDS.update(ev.id, data);
scheduler.updateView();
udpated = true;
}
else {
var data = updateResult.data;
dhtmlx.alert({
title: "Error",
type: "alert-error",
text: data.error
});
updated = false;
}
schedulerLayout.cells('b').progressOff();
}
return updated;
});
onBeforeEventChanged.zip (1.69 MB)