Do not delete an appointment, just mark it as deleted

Hello,

I have been using the scheduler for a mobile version for several weeks.
The integration takes place via Javascript, the dataProcessor, PHP and MySQL.

Currently I‘m faced with the task that when deleting an appointment this shouldn’t be deleted, rather only mark as deleted because the appointments are synchronized with a second database.

I thought of this:

dp.attachEvent(“onBeforeUpdate”, function(id, state, data){
if (state == “deleted”) {
data.DeletedField = 1;
return false;
} else {
return true;
}
});

However I don‘t know how to update the data afterwards in this function.

Short feedback.
After numerous attempts I found a solution:

		scheduler.attachEvent("onBeforeEventDelete", function(id,ev){ 
			ev.DeletedField = 1;
			scheduler.addEvent(ev);
			return true;
		});

Hi,

Thank you for sharing the solution.
But if you don’t want to delete event, you need to “return false” from the handler and do not add the event with the same id value.
You can just hide events that marked as deleted (with value 1 as DeletedField in your case). Use filtering for it
https://docs.dhtmlx.com/scheduler/filtering.html

Hello Polina,

thanks for your feedback and your time.

I tried it first with scheduler.updateEvent(id), but that didn‘t work.
Only with scheduler.addEvent(ev) the record will actually be updated.
And with return false the view is not updated and the appointment is still visible. With return true the view is updated and the appointment is no longer visible (and isn’t deleted), since I already filter for this field.

Maybe it’s a bug, but it works for me :wink: